summaryrefslogtreecommitdiff
path: root/Lib/test/test_module.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-08-01 19:20:31 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-08-01 19:20:31 +0200
commit4ed328c4d770ad0fa6ec278cae7b706c5f3da4ce (patch)
tree6e8115cf3fa313ddd7bb24fb59e16df464a80ca6 /Lib/test/test_module.py
parent5284f80268ea58f426d2cd1ebca02b702d16cca5 (diff)
downloadcpython-git-4ed328c4d770ad0fa6ec278cae7b706c5f3da4ce.tar.gz
Add a test for module weakrefability
Diffstat (limited to 'Lib/test/test_module.py')
-rw-r--r--Lib/test/test_module.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
index 3000cec55f..5a9b503485 100644
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -1,5 +1,6 @@
# 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')