Show More
@@ -5,7 +5,13 b'' | |||||
5 | # Imports |
|
5 | # Imports | |
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 |
|
7 | |||
|
8 | import os | |||
|
9 | import sys | |||
|
10 | ||||
|
11 | import nose.tools as nt | |||
|
12 | ||||
8 | from IPython.testing import decorators as dec |
|
13 | from IPython.testing import decorators as dec | |
|
14 | from IPython.utils.tempdir import TemporaryDirectory | |||
9 | from IPython.lib.deepreload import reload as dreload |
|
15 | from IPython.lib.deepreload import reload as dreload | |
10 |
|
16 | |||
11 | #----------------------------------------------------------------------------- |
|
17 | #----------------------------------------------------------------------------- | |
@@ -14,6 +20,7 b' from IPython.lib.deepreload import reload as dreload' | |||||
14 |
|
20 | |||
15 | @dec.skipif_not_numpy |
|
21 | @dec.skipif_not_numpy | |
16 | def test_deepreload_numpy(): |
|
22 | def test_deepreload_numpy(): | |
|
23 | "Test that NumPy can be deep reloaded." | |||
17 | import numpy |
|
24 | import numpy | |
18 | exclude = [ |
|
25 | exclude = [ | |
19 | # Standard exclusions: |
|
26 | # Standard exclusions: | |
@@ -22,3 +29,24 b' def test_deepreload_numpy():' | |||||
22 | 'unittest', |
|
29 | 'unittest', | |
23 | ] |
|
30 | ] | |
24 | dreload(numpy, exclude=exclude) |
|
31 | dreload(numpy, exclude=exclude) | |
|
32 | ||||
|
33 | def test_deepreload(): | |||
|
34 | "Test that dreload does deep reloads and skips excluded modules." | |||
|
35 | with TemporaryDirectory() as tmpdir: | |||
|
36 | sys.path.insert(0, tmpdir) | |||
|
37 | with open(os.path.join(tmpdir, 'A.py'), 'w') as f: | |||
|
38 | f.write("class Object(object):\n pass\n") | |||
|
39 | with open(os.path.join(tmpdir, 'B.py'), 'w') as f: | |||
|
40 | f.write("import A\n") | |||
|
41 | import A | |||
|
42 | import B | |||
|
43 | ||||
|
44 | # Test that A is not reloaded. | |||
|
45 | obj = A.Object() | |||
|
46 | dreload(B, exclude=['A']) | |||
|
47 | nt.assert_is_instance(obj, A.Object) | |||
|
48 | ||||
|
49 | # Test that A is reloaded. | |||
|
50 | obj = A.Object() | |||
|
51 | dreload(B) | |||
|
52 | nt.assert_not_is_instance(obj, A.Object) |
General Comments 0
You need to be logged in to leave comments.
Login now