From a55dc7b41181641bc05c93ebdf040dbea9210096 2011-10-08 21:10:56 From: Thomas Kluyver Date: 2011-10-08 21:10:56 Subject: [PATCH] Use AssertPrints in test_magic. --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 102f05d..bd3ab4f 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -174,17 +174,10 @@ def test_macro_run(): ip.run_cell(cmd) nt.assert_equal(ip.user_ns["test"].value, py3compat.doctest_refactor_print("a+=1\nprint a\n")) - original_stdout = sys.stdout - new_stdout = StringIO() - sys.stdout = new_stdout - try: + with tt.AssertPrints("12"): ip.run_cell("test") - nt.assert_true("12" in new_stdout.getvalue()) + with tt.AssertPrints("13"): ip.run_cell("test") - nt.assert_true("13" in new_stdout.getvalue()) - finally: - sys.stdout = original_stdout - new_stdout.close() # XXX failing for now, until we get clearcmd out of quarantine. But we should