def test_printing_tb_skip_cur_frame(): out = StringIO() with printing_tb(reraise=False, file_=out, skip_cur_frame=True): f(10) assert_smart_equals_ref('test_print.printing_tb_skip_cur_frame', out.getvalue())
def test_logger_as_file_lines(caplog): with printing_tb(reraise=False, file_=LoggerAsFile(logging.getLogger('test-logger'), separate_lines=True)): f(10) assert_smart_equals_ref('test_print.logger_as_file_lines', caplog.text)
def test_printing_tb_to_tty(): if sys.platform == 'win32': return out = StringIO() out.isatty = lambda: True with printing_tb(reraise=False, file_=out): f(10) assert_smart_equals_ref('test_print.printing_tb_to_tty', out.getvalue())
def test_printing_tb_reraise(): out = StringIO() with pytest.raises(ZeroDivisionError): with printing_tb(reraise=True, file_=out): f(10)
def test_printing_tb(): out = StringIO() with printing_tb(reraise=False, file_=out, flush=True): f(10) assert_smart_equals_ref('test_print.printing_tb', out.getvalue())