From ebc00149e62706de0f0aa0066b7eaf42886df611 2011-05-06 13:33:27 From: Thomas Kluyver Date: 2011-05-06 13:33:27 Subject: [PATCH] Create test for %xdel magic. Not passing yet, although the equivalent works in interactive use. --- diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 671d7ea..5ead7eb 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -394,6 +394,22 @@ def test_reset_hard(): nt.assert_equal(monitor, []) _ip.magic_reset("-f") nt.assert_equal(monitor, [1]) + +class TestXdel(tt.TempFileMixin): + def test_xdel(self): + """Test that references from %run are cleared by xdel.""" + src = ("class A(object):\n" + " monitor = []\n" + " def __del__(self):\n" + " self.monitor.append(1)\n" + "a = A()\n") + self.mktmp(src) + _ip.magic("run %s" % self.fname) + _ip.run_cell("a") + monitor = _ip.user_ns["A"].monitor + nt.assert_equal(monitor, []) + _ip.magic("xdel a") + nt.assert_equal(monitor, [1]) def doctest_who(): """doctest for %who