Changeset 391 for python/trunk/Lib/test/test_module.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/test/test_module.py
r2 r391 1 1 # Test the module type 2 2 import unittest 3 from test.test_support import run_unittest 3 from test.test_support import run_unittest, gc_collect 4 4 5 5 import sys … … 11 11 # and __doc__ is None 12 12 foo = ModuleType.__new__(ModuleType) 13 self. failUnless(foo.__dict__ is None)13 self.assertTrue(foo.__dict__ is None) 14 14 self.assertRaises(SystemError, dir, foo) 15 15 try: … … 54 54 self.assertEqual(foo.__dict__, 55 55 {"__name__": "foo", "__doc__": "foodoc", "bar": 42}) 56 self.failUnless(foo.__dict__ is d) 56 self.assertTrue(foo.__dict__ is d) 57 58 @unittest.expectedFailure 59 def test_dont_clear_dict(self): 60 # See issue 7140. 61 def f(): 62 foo = ModuleType("foo") 63 foo.bar = 4 64 return foo 65 gc_collect() 66 self.assertEqual(f().__dict__["bar"], 4) 67 68 def test_clear_dict_in_ref_cycle(self): 69 destroyed = [] 70 m = ModuleType("foo") 71 m.destroyed = destroyed 72 s = """class A: 73 def __del__(self, destroyed=destroyed): 74 destroyed.append(1) 75 a = A()""" 76 exec(s, m.__dict__) 77 del m 78 gc_collect() 79 self.assertEqual(destroyed, [1]) 57 80 58 81 def test_main():
Note:
See TracChangeset
for help on using the changeset viewer.