Skip to content
Browse files

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.
  • Loading branch information...
1 parent 9281c5b commit 4d338ff838305a0a2fc9c54caf435cb892568ad5 @takluyver committed
Showing with 5 additions and 8 deletions.
  1. +5 −8 IPython/core/tests/test_magic.py
View
13 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

0 comments on commit 4d338ff

Please sign in to comment.
Something went wrong with that request. Please try again.