Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/test/test_module.py

    r2 r391  
    11# Test the module type
    22import unittest
    3 from test.test_support import run_unittest
     3from test.test_support import run_unittest, gc_collect
    44
    55import sys
     
    1111        # and __doc__ is None
    1212        foo = ModuleType.__new__(ModuleType)
    13         self.failUnless(foo.__dict__ is None)
     13        self.assertTrue(foo.__dict__ is None)
    1414        self.assertRaises(SystemError, dir, foo)
    1515        try:
     
    5454        self.assertEqual(foo.__dict__,
    5555              {"__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)
     75a = A()"""
     76        exec(s, m.__dict__)
     77        del m
     78        gc_collect()
     79        self.assertEqual(destroyed, [1])
    5780
    5881def test_main():
Note: See TracChangeset for help on using the changeset viewer.