Show More
@@ -15,6 +15,7 b' from __future__ import absolute_import' | |||
|
15 | 15 | |
|
16 | 16 | import functools |
|
17 | 17 | import os |
|
18 | from os.path import join as pjoin | |
|
18 | 19 | import random |
|
19 | 20 | import sys |
|
20 | 21 | import tempfile |
@@ -359,6 +360,17 b' tclass.py: deleting object: C-third' | |||
|
359 | 360 | self.mktmp(src) |
|
360 | 361 | _ip.magic('run -t -N 1 %s' % self.fname) |
|
361 | 362 | _ip.magic('run -t -N 10 %s' % self.fname) |
|
363 | ||
|
364 | def test_ignore_sys_exit(self): | |
|
365 | """Test the -e option to ignore sys.exit()""" | |
|
366 | src = "import sys; sys.exit(1)" | |
|
367 | self.mktmp(src) | |
|
368 | with tt.AssertPrints('SystemExit'): | |
|
369 | _ip.magic('run %s' % self.fname) | |
|
370 | ||
|
371 | with tt.AssertNotPrints('SystemExit'): | |
|
372 | _ip.magic('run -e %s' % self.fname) | |
|
373 | ||
|
362 | 374 | |
|
363 | 375 | |
|
364 | 376 | class TestMagicRunWithPackage(unittest.TestCase): |
@@ -431,3 +443,16 b' class TestMagicRunWithPackage(unittest.TestCase):' | |||
|
431 | 443 | @with_fake_debugger |
|
432 | 444 | def test_debug_run_submodule_with_relative_import(self): |
|
433 | 445 | self.check_run_submodule('relative', '-d') |
|
446 | ||
|
447 | def test_run__name__(): | |
|
448 | with TemporaryDirectory() as td: | |
|
449 | path = pjoin(td, 'foo.py') | |
|
450 | with open(path, 'w') as f: | |
|
451 | f.write("q = __name__") | |
|
452 | ||
|
453 | _ip.user_ns.pop('q', None) | |
|
454 | _ip.magic('run {}'.format(path)) | |
|
455 | nt.assert_equal(_ip.user_ns.pop('q'), '__main__') | |
|
456 | ||
|
457 | _ip.magic('run -n {}'.format(path)) | |
|
458 | nt.assert_equal(_ip.user_ns.pop('q'), 'foo') |
General Comments 0
You need to be logged in to leave comments.
Login now