From 4d338ff838305a0a2fc9c54caf435cb892568ad5 2011-10-14 23:39:27 From: Thomas Kluyver Date: 2011-10-14 23:39:27 Subject: [PATCH] Fix tests for cpaste which no longer get error raised to them. Less elegant than before, because we now look for the traceback being printed. --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index afba614..e4ebde9 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -326,15 +326,12 @@ def check_cpaste(code, should_fail=False): sys.stdin = src try: - _ip.magic('cpaste') - except: + context = tt.AssertPrints if should_fail else tt.AssertNotPrints + with context("Traceback (most recent call last)"): + _ip.magic('cpaste') + if not should_fail: - raise AssertionError("Failure not expected : '%s'" % - code) - else: - assert _ip.user_ns['code_ran'] - if should_fail: - raise AssertionError("Failure expected : '%s'" % code) + assert _ip.user_ns['code_ran'] finally: sys.stdin = stdin_save