Traceback produced if the line where the error occurred is missing? https://github.com/ipython/ipython/issues/1456
(self)
| 56 | |
| 57 | class ChangedPyFileTest(unittest.TestCase): |
| 58 | def test_changing_py_file(self): |
| 59 | """Traceback produced if the line where the error occurred is missing? |
| 60 | |
| 61 | https://github.com/ipython/ipython/issues/1456 |
| 62 | """ |
| 63 | with TemporaryDirectory() as td: |
| 64 | fname = os.path.join(td, "foo.py") |
| 65 | with open(fname, "w") as f: |
| 66 | f.write(file_1) |
| 67 | |
| 68 | with prepended_to_syspath(td): |
| 69 | ip.run_cell("import foo") |
| 70 | |
| 71 | with tt.AssertPrints("ZeroDivisionError"): |
| 72 | ip.run_cell("foo.f()") |
| 73 | |
| 74 | # Make the file shorter, so the line of the error is missing. |
| 75 | with open(fname, "w") as f: |
| 76 | f.write(file_2) |
| 77 | |
| 78 | # For some reason, this was failing on the *second* call after |
| 79 | # changing the file, so we call f() twice. |
| 80 | with tt.AssertNotPrints("Internal Python error", channel='stderr'): |
| 81 | with tt.AssertPrints("ZeroDivisionError"): |
| 82 | ip.run_cell("foo.f()") |
| 83 | with tt.AssertPrints("ZeroDivisionError"): |
| 84 | ip.run_cell("foo.f()") |
| 85 | |
| 86 | iso_8859_5_file = u'''# coding: iso-8859-5 |
| 87 |
nothing calls this directly
no test coverage detected