##// END OF EJS Templates
Always reset after `%run -i` in tests....
Craig Citro -
Show More
@@ -6,6 +6,9 b' verify subtle object deletion and reference counting issues, the %run tests'
6 6 will be kept in this separate file. This makes it easier to aggregate in one
7 7 place the tricks needed to handle it; most other magics are much easier to test
8 8 and we do so in a common test_magic file.
9
10 Note that any test using `run -i` should make sure to do a `reset` afterwards,
11 as otherwise it may influence later tests.
9 12 """
10 13
11 14 # Copyright (c) IPython Development Team.
@@ -317,13 +320,19 b' tclass.py: deleting object: C-third'
317 320 src = "yy = zz\n"
318 321 self.mktmp(src)
319 322 _ip.run_cell("zz = 23")
320 _ip.magic('run -i %s' % self.fname)
321 nt.assert_equal(_ip.user_ns['yy'], 23)
322 _ip.magic('reset -f')
323 try:
324 _ip.magic('run -i %s' % self.fname)
325 nt.assert_equal(_ip.user_ns['yy'], 23)
326 finally:
327 _ip.magic('reset -f')
328
323 329 _ip.run_cell("zz = 23")
324 _ip.magic('run -i %s' % self.fname)
325 nt.assert_equal(_ip.user_ns['yy'], 23)
326
330 try:
331 _ip.magic('run -i %s' % self.fname)
332 nt.assert_equal(_ip.user_ns['yy'], 23)
333 finally:
334 _ip.magic('reset -f')
335
327 336 def test_unicode(self):
328 337 """Check that files in odd encodings are accepted."""
329 338 mydir = os.path.dirname(__file__)
@@ -505,8 +514,11 b' def test_run__name__():'
505 514 _ip.magic('run -n {}'.format(path))
506 515 nt.assert_equal(_ip.user_ns.pop('q'), 'foo')
507 516
508 _ip.magic('run -i -n {}'.format(path))
509 nt.assert_equal(_ip.user_ns.pop('q'), 'foo')
517 try:
518 _ip.magic('run -i -n {}'.format(path))
519 nt.assert_equal(_ip.user_ns.pop('q'), 'foo')
520 finally:
521 _ip.magic('reset -f')
510 522
511 523
512 524 def test_run_tb():
General Comments 0
You need to be logged in to leave comments. Login now