Show More
@@ -404,11 +404,26 b' class TestXdel(tt.TempFileMixin):' | |||
|
404 | 404 | " self.monitor.append(1)\n" |
|
405 | 405 | "a = A()\n") |
|
406 | 406 | self.mktmp(src) |
|
407 | # %run creates some hidden references... | |
|
407 | 408 | _ip.magic("run %s" % self.fname) |
|
409 | # ... as does the displayhook. | |
|
408 | 410 | _ip.run_cell("a") |
|
411 | a = _ip.user_ns["a"] | |
|
409 | 412 | monitor = _ip.user_ns["A"].monitor |
|
410 | 413 | nt.assert_equal(monitor, []) |
|
411 | 414 | _ip.magic("xdel a") |
|
415 | ||
|
416 | # The testing framework stores extra references - we kill those | |
|
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 | ||
|
426 | # Check that a's __del__ method has been called. | |
|
412 | 427 | nt.assert_equal(monitor, [1]) |
|
413 | 428 | |
|
414 | 429 | def doctest_who(): |
@@ -132,6 +132,15 b' class ipnsdict(dict):' | |||
|
132 | 132 | # correct for that ourselves, to ensure consitency with the 'real' |
|
133 | 133 | # ipython. |
|
134 | 134 | self['__builtins__'] = __builtin__ |
|
135 | ||
|
136 | def killrefs(self, obj): | |
|
137 | """For part of the testing, we need to be able to remove | |
|
138 | references to an object, which would otherwise be kept in | |
|
139 | _savedict.""" | |
|
140 | todel = [n for n, o in self._savedict.iteritems() if o is obj] | |
|
141 | for n in todel: | |
|
142 | del self._savedict[n] | |
|
143 | ||
|
135 | 144 | |
|
136 | 145 | |
|
137 | 146 | def get_ipython(): |
General Comments 0
You need to be logged in to leave comments.
Login now