Show More
@@ -93,6 +93,7 b' class ExtensionManager(Configurable):' | |||||
93 |
|
93 | |||
94 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
94 | from IPython.utils.syspathcontext import prepended_to_syspath | |
95 |
|
95 | |||
|
96 | with self.shell.builtin_trap: | |||
96 | if module_str not in sys.modules: |
|
97 | if module_str not in sys.modules: | |
97 | with prepended_to_syspath(self.ipython_extension_dir): |
|
98 | with prepended_to_syspath(self.ipython_extension_dir): | |
98 | __import__(module_str) |
|
99 | __import__(module_str) |
@@ -19,6 +19,12 b' def load_ipython_extension(ip):' | |||||
19 | print("Running ext2 load") |
|
19 | print("Running ext2 load") | |
20 | """ |
|
20 | """ | |
21 |
|
21 | |||
|
22 | ext3_content = """ | |||
|
23 | def load_ipython_extension(ip): | |||
|
24 | ip2 = get_ipython() | |||
|
25 | print(ip is ip2) | |||
|
26 | """ | |||
|
27 | ||||
22 | def test_extension_loading(): |
|
28 | def test_extension_loading(): | |
23 | em = get_ipython().extension_manager |
|
29 | em = get_ipython().extension_manager | |
24 | with TemporaryDirectory() as td: |
|
30 | with TemporaryDirectory() as td: | |
@@ -68,6 +74,23 b' def test_extension_loading():' | |||||
68 | with tt.AssertPrints("Running ext2 load"): |
|
74 | with tt.AssertPrints("Running ext2 load"): | |
69 | em.reload_extension('ext2') |
|
75 | em.reload_extension('ext2') | |
70 |
|
76 | |||
|
77 | ||||
|
78 | def test_extension_builtins(): | |||
|
79 | em = get_ipython().extension_manager | |||
|
80 | with TemporaryDirectory() as td: | |||
|
81 | ext3 = os.path.join(td, 'ext3.py') | |||
|
82 | with open(ext3, 'w') as f: | |||
|
83 | f.write(ext3_content) | |||
|
84 | ||||
|
85 | assert 'ext3' not in em.loaded | |||
|
86 | ||||
|
87 | with prepended_to_syspath(td): | |||
|
88 | # Load extension | |||
|
89 | with tt.AssertPrints("True"): | |||
|
90 | assert em.load_extension('ext3') is None | |||
|
91 | assert 'ext3' in em.loaded | |||
|
92 | ||||
|
93 | ||||
71 | def test_non_extension(): |
|
94 | def test_non_extension(): | |
72 | em = get_ipython().extension_manager |
|
95 | em = get_ipython().extension_manager | |
73 | nt.assert_equal(em.load_extension('sys'), "no load function") |
|
96 | nt.assert_equal(em.load_extension('sys'), "no load function") |
General Comments 0
You need to be logged in to leave comments.
Login now