Show More
@@ -1,35 +1,36 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Test suite for the deepreload module.""" |
|
2 | """Test suite for the deepreload module.""" | |
3 |
|
3 | |||
4 | # Copyright (c) IPython Development Team. |
|
4 | # Copyright (c) IPython Development Team. | |
5 | # Distributed under the terms of the Modified BSD License. |
|
5 | # Distributed under the terms of the Modified BSD License. | |
6 |
|
6 | |||
7 | from pathlib import Path |
|
7 | from pathlib import Path | |
8 |
|
8 | |||
9 | import nose.tools as nt |
|
9 | import nose.tools as nt | |
10 |
|
10 | |||
11 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
11 | from IPython.utils.syspathcontext import prepended_to_syspath | |
12 | from IPython.utils.tempdir import TemporaryDirectory |
|
12 | from IPython.utils.tempdir import TemporaryDirectory | |
13 | from IPython.lib.deepreload import reload as dreload |
|
13 | from IPython.lib.deepreload import reload as dreload | |
14 |
|
14 | |||
|
15 | ||||
15 | def test_deepreload(): |
|
16 | def test_deepreload(): | |
16 | "Test that dreload does deep reloads and skips excluded modules." |
|
17 | "Test that dreload does deep reloads and skips excluded modules." | |
17 | with TemporaryDirectory() as tmpdir: |
|
18 | with TemporaryDirectory() as tmpdir: | |
18 | with prepended_to_syspath(tmpdir): |
|
19 | with prepended_to_syspath(tmpdir): | |
19 | tmpdirpath = Path(tmpdir) |
|
20 | tmpdirpath = Path(tmpdir) | |
20 |
with open( |
|
21 | with open(tmpdirpath / "A.py", "w") as f: | |
21 | f.write("class Object(object):\n pass\n") |
|
22 | f.write("class Object(object):\n pass\n") | |
22 |
with open( |
|
23 | with open(tmpdirpath / "B.py", "w") as f: | |
23 | f.write("import A\n") |
|
24 | f.write("import A\n") | |
24 | import A |
|
25 | import A | |
25 | import B |
|
26 | import B | |
26 |
|
27 | |||
27 | # Test that A is not reloaded. |
|
28 | # Test that A is not reloaded. | |
28 | obj = A.Object() |
|
29 | obj = A.Object() | |
29 |
dreload(B, exclude=[ |
|
30 | dreload(B, exclude=["A"]) | |
30 | nt.assert_true(isinstance(obj, A.Object)) |
|
31 | nt.assert_true(isinstance(obj, A.Object)) | |
31 |
|
32 | |||
32 | # Test that A is reloaded. |
|
33 | # Test that A is reloaded. | |
33 | obj = A.Object() |
|
34 | obj = A.Object() | |
34 | dreload(B) |
|
35 | dreload(B) | |
35 | nt.assert_false(isinstance(obj, A.Object)) |
|
36 | nt.assert_false(isinstance(obj, A.Object)) |
General Comments 0
You need to be logged in to leave comments.
Login now