Show More
@@ -93,6 +93,7 b' class ExtensionManager(Configurable):' | |||
|
93 | 93 | |
|
94 | 94 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
95 | 95 | |
|
96 | with self.shell.builtin_trap: | |
|
96 | 97 | if module_str not in sys.modules: |
|
97 | 98 | with prepended_to_syspath(self.ipython_extension_dir): |
|
98 | 99 | __import__(module_str) |
@@ -19,6 +19,12 b' def load_ipython_extension(ip):' | |||
|
19 | 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 | 28 | def test_extension_loading(): |
|
23 | 29 | em = get_ipython().extension_manager |
|
24 | 30 | with TemporaryDirectory() as td: |
@@ -68,6 +74,23 b' def test_extension_loading():' | |||
|
68 | 74 | with tt.AssertPrints("Running ext2 load"): |
|
69 | 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 | 94 | def test_non_extension(): |
|
72 | 95 | em = get_ipython().extension_manager |
|
73 | 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