MCPcopy Create free account
hub / github.com/ipython/ipython / test_changing_py_file

Method test_changing_py_file

IPython/core/tests/test_ultratb.py:58–84  ·  view source on GitHub ↗

Traceback produced if the line where the error occurred is missing? https://github.com/ipython/ipython/issues/1456

(self)

Source from the content-addressed store, hash-verified

56
57class 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
86iso_8859_5_file = u'''# coding: iso-8859-5
87

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
run_cellMethod · 0.45

Tested by

no test coverage detected