##// END OF EJS Templates
Remove object references kept by the test suite in a better way.
Thomas Kluyver -
Show More
@@ -408,20 +408,11 b' class TestXdel(tt.TempFileMixin):'
408 _ip.magic("run %s" % self.fname)
408 _ip.magic("run %s" % self.fname)
409 # ... as does the displayhook.
409 # ... as does the displayhook.
410 _ip.run_cell("a")
410 _ip.run_cell("a")
411 a = _ip.user_ns["a"]
411
412 monitor = _ip.user_ns["A"].monitor
412 monitor = _ip.user_ns["A"].monitor
413 nt.assert_equal(monitor, [])
413 nt.assert_equal(monitor, [])
414 _ip.magic("xdel a")
415
414
416 # The testing framework stores extra references - we kill those
415 _ip.magic("xdel a")
417 # here. See IPython.testing.globalipapp.ipnsdict.
418 _ip.user_ns.killrefs(a)
419 del a
420
421 # For some reason the test doesn't pass if this is removed.
422 # TODO: Work out why, and improve the test.
423 f = sys._getframe()
424 print f.f_locals
425
416
426 # Check that a's __del__ method has been called.
417 # Check that a's __del__ method has been called.
427 nt.assert_equal(monitor, [1])
418 nt.assert_equal(monitor, [1])
@@ -133,14 +133,15 b' class ipnsdict(dict):'
133 # ipython.
133 # ipython.
134 self['__builtins__'] = __builtin__
134 self['__builtins__'] = __builtin__
135
135
136 def killrefs(self, obj):
136 def __delitem__(self, key):
137 """For part of the testing, we need to be able to remove
137 """Part of the test suite checks that we can release all
138 references to an object, which would otherwise be kept in
138 references to an object. So we need to make sure that we're not
139 _savedict."""
139 keeping a reference in _savedict."""
140 todel = [n for n, o in self._savedict.iteritems() if o is obj]
140 dict.__delitem__(self, key)
141 for n in todel:
141 try:
142 del self._savedict[n]
142 del self._savedict[key]
143
143 except KeyError:
144 pass
144
145
145
146
146 def get_ipython():
147 def get_ipython():
General Comments 0
You need to be logged in to leave comments. Login now