MCPcopy Index your code
hub / github.com/ipython/ipython / test_changing_py_file

Method test_changing_py_file

tests/test_ultratb.py:51–77  ·  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

49
50class 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
80iso_8859_5_file = '''# coding: iso-8859-5

Callers

nothing calls this directly

Calls 3

writeMethod · 0.45
run_cellMethod · 0.45

Tested by

no test coverage detected