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

Function test_deepreload

tests/test_deepreload.py:18–47  ·  view source on GitHub ↗

Test that dreload does deep reloads and skips excluded modules.

()

Source from the content-addressed store, hash-verified

16
17
18def test_deepreload():
19 "Test that dreload does deep reloads and skips excluded modules."
20 with TemporaryDirectory() as tmpdir:
21 with prepended_to_syspath(tmpdir):
22 tmpdirpath = Path(tmpdir)
23 with open(tmpdirpath / "A.py", "w", encoding="utf-8") as f:
24 f.write("class Object:\n pass\nok = True\n")
25 with open(tmpdirpath / "B.py", "w", encoding="utf-8") as f:
26 f.write("import A\nassert A.ok, 'we are fine'\n")
27 import A
28 import B
29
30 # Test that A is not reloaded.
31 obj = A.Object()
32 dreload(B, exclude=["A"])
33 assert isinstance(obj, A.Object) is True
34
35 # Test that an import failure will not blow-up us.
36 A.ok = False
37 with pytest.raises(AssertionError, match="we are fine"):
38 dreload(B, exclude=["A"])
39 assert len(modules_reloading) == 0
40 assert not A.ok
41
42 # Test that A is reloaded.
43 obj = A.Object()
44 A.ok = False
45 dreload(B)
46 assert A.ok
47 assert isinstance(obj, A.Object) is False
48
49
50def test_not_module():

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…