| 227 | del ip.user_ns['foo'] |
| 228 | |
| 229 | def test_changing_py_file(self): |
| 230 | with TemporaryDirectory() as td: |
| 231 | fname = os.path.join(td, "foo.py") |
| 232 | with open(fname, 'w') as f: |
| 233 | f.write(se_file_1) |
| 234 | |
| 235 | with tt.AssertPrints(["7/", "SyntaxError"]): |
| 236 | ip.magic("run " + fname) |
| 237 | |
| 238 | # Modify the file |
| 239 | with open(fname, 'w') as f: |
| 240 | f.write(se_file_2) |
| 241 | |
| 242 | # The SyntaxError should point to the correct line |
| 243 | with tt.AssertPrints(["7/", "SyntaxError"]): |
| 244 | ip.magic("run " + fname) |
| 245 | |
| 246 | def test_non_syntaxerror(self): |
| 247 | # SyntaxTB may be called with an error other than a SyntaxError |