Show More
@@ -29,7 +29,7 b' def check_cpaste(code, should_fail=False):' | |||
|
29 | 29 | """Execute code via 'cpaste' and ensure it was executed, unless |
|
30 | 30 | should_fail is set. |
|
31 | 31 | """ |
|
32 |
|
|
|
32 | ip.user_ns['code_ran'] = False | |
|
33 | 33 | |
|
34 | 34 | src = StringIO() |
|
35 | 35 | if not hasattr(src, 'encoding'): |
@@ -45,10 +45,10 b' def check_cpaste(code, should_fail=False):' | |||
|
45 | 45 | try: |
|
46 | 46 | context = tt.AssertPrints if should_fail else tt.AssertNotPrints |
|
47 | 47 | with context("Traceback (most recent call last)"): |
|
48 |
|
|
|
48 | ip.magic('cpaste') | |
|
49 | 49 | |
|
50 | 50 | if not should_fail: |
|
51 |
assert |
|
|
51 | assert ip.user_ns['code_ran'] | |
|
52 | 52 | finally: |
|
53 | 53 | sys.stdin = stdin_save |
|
54 | 54 | |
@@ -60,7 +60,7 b' def test_cpaste():' | |||
|
60 | 60 | def runf(): |
|
61 | 61 | """Marker function: sets a flag when executed. |
|
62 | 62 | """ |
|
63 |
|
|
|
63 | ip.user_ns['code_ran'] = True | |
|
64 | 64 | return 'runf' # return string so '+ runf()' doesn't result in success |
|
65 | 65 | |
|
66 | 66 | tests = {'pass': ["runf()", |
@@ -80,7 +80,7 b' def test_cpaste():' | |||
|
80 | 80 | if not PY31: |
|
81 | 81 | tests['fail'].append("++ runf()") |
|
82 | 82 | |
|
83 |
|
|
|
83 | ip.user_ns['runf'] = runf | |
|
84 | 84 | |
|
85 | 85 | for code in tests['pass']: |
|
86 | 86 | check_cpaste(code) |
General Comments 0
You need to be logged in to leave comments.
Login now