mirror of
https://github.com/datafolklabs/cement.git
synced 2026-02-06 11:16:46 +00:00
38 lines
926 B
Python
38 lines
926 B
Python
|
|
from cement import init_defaults
|
|
from cement.utils.test import TestApp
|
|
|
|
|
|
class ScrubApp(TestApp):
|
|
class Meta:
|
|
extensions = ['scrub', 'print', 'json']
|
|
scrub = [
|
|
('foo', '$$$'),
|
|
('bar', '***'),
|
|
]
|
|
|
|
|
|
def test_scrub():
|
|
with ScrubApp(argv=['--scrub']) as app:
|
|
app.run()
|
|
app.print('foobar foo bar')
|
|
assert app.last_rendered[1] == '$$$*** $$$ ***\n'
|
|
|
|
# coverage
|
|
assert app.scrub(None) is None
|
|
|
|
|
|
def test_argument():
|
|
META = init_defaults('controller.scrub')
|
|
META['controller.scrub']['argument_options'] = ['--not-scrub']
|
|
META['controller.scrub']['argument_help'] = 'not scrub'
|
|
|
|
class MyScrubApp(ScrubApp):
|
|
class Meta:
|
|
meta_defaults = META
|
|
|
|
with MyScrubApp(argv=['--not-scrub']) as app:
|
|
app.run()
|
|
app.print('foobar foo bar')
|
|
assert app.last_rendered[1] == '$$$*** $$$ ***\n'
|