Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
output = MyOutput(Output.VERBOSITY_QUIET, True)
self.assertEqual(Output.VERBOSITY_QUIET, output.get_verbosity())
self.assertTrue(output.is_decorated())
Application.render_exception() displays formatted exception.
"""
application = Application()
application.set_auto_exit(False)
os.environ['COLUMNS'] = '120'
tester = ApplicationTester(application)
tester.run([('command', 'foo')], {'decorated': False})
self.assertEqual(
self.open_fixture('application_renderexception1.txt'),
tester.get_display()
)
tester.run([('command', 'foo')],
{'decorated': False, 'verbosity': Output.VERBOSITY_VERBOSE})
self.assertRegex(
tester.get_display(),
'Exception trace'
)
tester.run([('command', 'list'), ('--foo', True)], {'decorated': False})
self.assertEqual(
self.open_fixture('application_renderexception2.txt'),
tester.get_display()
)
application.add(Foo3Command())
tester = ApplicationTester(application)
tester.run([('command', 'foo3:bar')], {'decorated': False})
self.assertEqual(
self.open_fixture('application_renderexception3.txt'),
def test_init(self):
output = StreamOutput(self.stream, Output.VERBOSITY_QUIET, True)
self.assertEqual(Output.VERBOSITY_QUIET, output.get_verbosity())
self.assertTrue(output.is_decorated())
def __init__(self, verbosity=Output.VERBOSITY_NORMAL, decorated=None, formatter=None):
super(MyOutput, self).__init__(verbosity, decorated, formatter)
self.output = ''
def _determine_best_format(self):
verbosity = self._output.get_verbosity()
if verbosity == Output.VERBOSITY_VERBOSE:
if self._max:
return 'verbose'
return 'verbose_nomax'
elif verbosity == Output.VERBOSITY_VERY_VERBOSE:
if self._max:
return 'very_verbose'
return 'very_verbose_nomax'
elif verbosity == Output.VERBOSITY_DEBUG:
if self._max:
return 'debug'
return 'debug_nomax'
if self._max:
def _determine_best_format(self):
verbosity = self._output.get_verbosity()
decorated = self._output.is_decorated()
if verbosity == Output.VERBOSITY_VERBOSE:
if decorated:
return 'verbose'
return 'verbose_no_ansi'
elif verbosity in [Output.VERBOSITY_VERY_VERBOSE, Output.VERBOSITY_DEBUG]:
if decorated:
return 'very_verbose'
return 'very_verbose_no_ansi'
if decorated:
return 'normal'
return 'normal_no_ansi'
def _display(self):
if self._output.get_verbosity() == Output.VERBOSITY_QUIET:
return
self._overwrite(re.sub('(?i)%([a-z\-_]+)(?:\:([^%]+))?%', self._overwrite_callback, self.format))
def write(self, messages, newline=False, type=Output.OUTPUT_NORMAL):
self._do_write(messages, newline, False, type)
def display(self):
"""
Ouput the current progress string.
"""
if self._output.get_verbosity() == Output.VERBOSITY_QUIET:
return
if self._format is None:
self._set_real_format(self._internal_format or self._determine_best_format())
self._overwrite(re.sub('(?i)%([a-z\-_]+)(?:\:([^%]+))?%', self._overwrite_callback, self._format))