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