def test_color_bar_full(): """Assert that a complete 16-color bar draws properly.""" out = StringIO() term = MockTerminal(kind='xterm-256color', stream=out, force_styling=True) bar = ProgressBar(28, term) bar.update('HI', 28) eq_( out.getvalue(), u'\x1b7\x1b[25d\x1b[1mHI ' '\x1b(B\x1b[m \x1b[100m \x1b(B\x1b[m' '\x1b[47m\x1b(B\x1b[m\x1b8')
def test_monochrome_bar(): """Assert that the black-and-white bar draws properly when < 16 colors are available.""" out = StringIO() term = MonochromeTerminal(kind='xterm', stream=out, force_styling=True) assert term.number_of_colors < 16 bar = ProgressBar(28, term) bar.update('HI', 14) eq_( out.getvalue(), u'\x1b7\x1b[25d\x1b[1mHI ' '\x1b(B\x1b[m \x1b[7m \x1b(B\x1b[m' '_______\x1b8')
def test_color_bar_full(): """Assert that a complete 16-color bar draws properly.""" out = StringIO() term = MockTerminal(kind='xterm-256color', stream=out, force_styling=True) bar = ProgressBar(28, term) bar.update('HI', 28) eq_(out.getvalue(), ''.join([term.save, term.move(24, 0), term.bold('HI '), ' ', term.on_color(8)(' '), term.on_color(7)(''), term.restore]))
def test_monochrome_bar(): """Assert that the black-and-white bar draws properly when < 16 colors are available.""" out = StringIO() term = MonochromeTerminal(kind='xterm', stream=out, force_styling=True) assert term.number_of_colors < 16 bar = ProgressBar(28, term) bar.update('HI', 14) eq_(out.getvalue(), ''.join([term.save, term.move(24, 0), term.bold('HI '), ' ', term.reverse(' '), '_______', term.restore]))
def __init__(self, cwd, total_tests, stream, config=None): super(ProgressiveResult, self).__init__(stream, None, 0, config=config) self._cwd = cwd self._options = config.options self._term = Terminal(stream=stream, force_styling=config.options.with_styling) if self._term.is_a_tty or self._options.with_bar: # 1 in case test counting failed and returned 0 self.bar = ProgressBar(total_tests or 1, self._term, config.options.bar_filled_color, config.options.bar_empty_color) else: self.bar = NullProgressBar() # Declare errorclass-savviness so ErrorClassPlugins don't monkeypatch # half my methods away: self.errorClasses = {}