Show More
@@ -0,0 +1,12 b'' | |||
|
1 | # -*- coding: utf-8 -*- | |
|
2 | """ | |
|
3 | Useless IPython extension to test installing and loading extensions. | |
|
4 | """ | |
|
5 | some_vars = {'arq': 185} | |
|
6 | ||
|
7 | def load_ipython_extension(ip): | |
|
8 | # set up simplified quantity input | |
|
9 | ip.push(some_vars) | |
|
10 | ||
|
11 | def unload_ipython_extension(ip): | |
|
12 | ip.drop_by_id(some_vars) |
@@ -15,6 +15,7 b' import nose.tools as nt' | |||
|
15 | 15 | from IPython.testing import decorators as dec |
|
16 | 16 | from IPython.testing import tools as tt |
|
17 | 17 | from IPython.utils import py3compat |
|
18 | from IPython.utils.tempdir import TemporaryDirectory | |
|
18 | 19 | |
|
19 | 20 | #----------------------------------------------------------------------------- |
|
20 | 21 | # Test functions begin |
@@ -394,3 +395,20 b' def test_prun_quotes():' | |||
|
394 | 395 | "Test that prun does not clobber string escapes (GH #1302)" |
|
395 | 396 | _ip.magic("prun -q x = '\t'") |
|
396 | 397 | nt.assert_equal(_ip.user_ns['x'], '\t') |
|
398 | ||
|
399 | def test_extension(): | |
|
400 | tmpdir = TemporaryDirectory() | |
|
401 | orig_ipython_dir = _ip.ipython_dir | |
|
402 | try: | |
|
403 | _ip.ipython_dir = tmpdir.name | |
|
404 | nt.assert_raises(ImportError, _ip.magic, "load_ext daft_extension") | |
|
405 | url = os.path.join(os.path.dirname(__file__), "daft_extension.py") | |
|
406 | _ip.magic("install_ext %s" % url) | |
|
407 | _ip.user_ns.pop('arq', None) | |
|
408 | _ip.magic("load_ext daft_extension") | |
|
409 | tt.assert_equal(_ip.user_ns['arq'], 185) | |
|
410 | _ip.magic("unload_ext daft_extension") | |
|
411 | assert 'arq' not in _ip.user_ns | |
|
412 | finally: | |
|
413 | _ip.ipython_dir = orig_ipython_dir | |
|
414 |
General Comments 0
You need to be logged in to leave comments.
Login now