()
| 26 | """ |
| 27 | |
| 28 | def test_extension_loading(): |
| 29 | em = get_ipython().extension_manager |
| 30 | with TemporaryDirectory() as td: |
| 31 | ext1 = os.path.join(td, 'ext1.py') |
| 32 | with open(ext1, 'w') as f: |
| 33 | f.write(ext1_content) |
| 34 | |
| 35 | ext2 = os.path.join(td, 'ext2.py') |
| 36 | with open(ext2, 'w') as f: |
| 37 | f.write(ext2_content) |
| 38 | |
| 39 | with prepended_to_syspath(td): |
| 40 | assert 'ext1' not in em.loaded |
| 41 | assert 'ext2' not in em.loaded |
| 42 | |
| 43 | # Load extension |
| 44 | with tt.AssertPrints("Running ext1 load"): |
| 45 | assert em.load_extension('ext1') is None |
| 46 | assert 'ext1' in em.loaded |
| 47 | |
| 48 | # Should refuse to load it again |
| 49 | with tt.AssertNotPrints("Running ext1 load"): |
| 50 | assert em.load_extension('ext1') == 'already loaded' |
| 51 | |
| 52 | # Reload |
| 53 | with tt.AssertPrints("Running ext1 unload"): |
| 54 | with tt.AssertPrints("Running ext1 load", suppress=False): |
| 55 | em.reload_extension('ext1') |
| 56 | |
| 57 | # Unload |
| 58 | with tt.AssertPrints("Running ext1 unload"): |
| 59 | assert em.unload_extension('ext1') is None |
| 60 | |
| 61 | # Can't unload again |
| 62 | with tt.AssertNotPrints("Running ext1 unload"): |
| 63 | assert em.unload_extension('ext1') == 'not loaded' |
| 64 | assert em.unload_extension('ext2') == 'not loaded' |
| 65 | |
| 66 | # Load extension 2 |
| 67 | with tt.AssertPrints("Running ext2 load"): |
| 68 | assert em.load_extension('ext2') is None |
| 69 | |
| 70 | # Can't unload this |
| 71 | assert em.unload_extension('ext2') == 'no unload function' |
| 72 | |
| 73 | # But can reload it |
| 74 | with tt.AssertPrints("Running ext2 load"): |
| 75 | em.reload_extension('ext2') |
| 76 | |
| 77 | |
| 78 | def test_extension_builtins(): |
nothing calls this directly
no test coverage detected