MCPcopy Create free account
hub / github.com/ipython/ipython / test_xdel

Method test_xdel

IPython/core/tests/test_magic.py:554–573  ·  view source on GitHub ↗

Test that references from %run are cleared by xdel.

(self)

Source from the content-addressed store, hash-verified

552
553class TestXdel(tt.TempFileMixin):
554 def test_xdel(self):
555 """Test that references from %run are cleared by xdel."""
556 src = ("class A(object):\n"
557 " monitor = []\n"
558 " def __del__(self):\n"
559 " self.monitor.append(1)\n"
560 "a = A()\n")
561 self.mktmp(src)
562 # %run creates some hidden references...
563 _ip.magic("run %s" % self.fname)
564 # ... as does the displayhook.
565 _ip.run_cell("a")
566
567 monitor = _ip.user_ns["A"].monitor
568 nt.assert_equal(monitor, [])
569
570 _ip.magic("xdel a")
571
572 # Check that a's __del__ method has been called.
573 nt.assert_equal(monitor, [1])
574
575def doctest_who():
576 """doctest for %who

Callers

nothing calls this directly

Calls 3

mktmpMethod · 0.80
magicMethod · 0.45
run_cellMethod · 0.45

Tested by

no test coverage detected