test_magic.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:leetcode 作者: thomasyimgit 项目源码 文件源码
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)
        # %run creates some hidden references...
        _ip.magic("run %s" % self.fname)
        # ... as does the displayhook.
        _ip.run_cell("a")

        monitor = _ip.user_ns["A"].monitor
        nt.assert_equal(monitor, [])

        _ip.magic("xdel a")

        # Check that a's __del__ method has been called.
        nt.assert_equal(monitor, [1])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号