[Python-checkins] cpython: Add a test for module weakrefability
antoine.pitrou
python-checkins at python.org
Thu Aug 1 19:20:39 CEST 2013
http://hg.python.org/cpython/rev/cdddd3ed2ae1
changeset: 84950:cdddd3ed2ae1
user: Antoine Pitrou <solipsis at pitrou.net>
date: Thu Aug 01 19:20:31 2013 +0200
summary:
Add a test for module weakrefability
files:
Lib/test/test_module.py | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
--- 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 @@
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')
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list