Commit 4ed328c4 authored by Antoine Pitrou's avatar Antoine Pitrou

Add a test for module weakrefability

parent 5284f802
# Test the module type
import unittest
import weakref
from test.support import run_unittest, gc_collect
from test.script_helper import assert_python_ok
......@@ -95,6 +96,14 @@ a = A(destroyed)"""
gc_collect()
self.assertEqual(destroyed, [1])
def test_weakref(self):
m = ModuleType("foo")
wr = weakref.ref(m)
self.assertIs(wr(), m)
del m
gc_collect()
self.assertIs(wr(), None)
def test_module_repr_minimal(self):
# reprs when modules have no __file__, __name__, or __loader__
m = ModuleType('foo')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment