def test_colours_warnings(mocker): mocked_getframe = mocker.patch('sys._getframe') mocked_getframe.side_effect = ValueError() v = debug.format('x') s = normalise_output(v.str(True)) assert s.startswith('\x1b[35m<unknown>'), repr(s) s2 = strip_ansi(s) assert s2 == v.str(), repr(s2)
def test_colours_warnings(mocker): mocked_getframe = mocker.patch('sys._getframe') mocked_getframe.side_effect = ValueError() v = debug.format('x') s = re.sub(r':\d{2,}', ':<line no>', v.str(True)) assert s.startswith('\x1b[35m<unknown>'), repr(s) s2 = strip_ansi(s) assert s2 == v.str(), repr(s2)
def test_print(capsys): pprint({1: 2, 3: 4}) stdout, stderr = capsys.readouterr() assert strip_ansi(stdout) == ( '{\n' ' 1: 2,\n' ' 3: 4,\n' '}\n') assert stderr == ''
def test_colours(): v = debug.format(range(6)) s = v.str(True) assert s.startswith('\x1b[35mtests'), repr(s) s2 = normalise_output(strip_ansi(s)) assert s2 == normalise_output(v.str()), repr(s2)
def test_colours(): v = pformat({1: 2, 3: 4}, highlight=True) assert v.startswith('\x1b'), repr(v) v2 = strip_ansi(v) assert v2 == pformat({1: 2, 3: 4}), repr(v2)
def test_colours(): v = debug.format(range(6)) s = re.sub(r':\d{2,}', ':<line no>', v.str(True)) assert s.startswith('\x1b[35mtests'), repr(s) s2 = strip_ansi(s) assert s2 == v.str(), repr(s2)