diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2013-07-31 23:14:08 +0200 | 
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-07-31 23:14:08 +0200 | 
| commit | dcedaf6e53fcba48aa8185d0dc27d832da2615aa (patch) | |
| tree | 1dec81865462dd482c792e3790280a1c8393e18f /Lib/test/test_module.py | |
| parent | c27cd71cd71e5b3f464f6994e2a73f201eb430ca (diff) | |
| download | cpython-git-dcedaf6e53fcba48aa8185d0dc27d832da2615aa.tar.gz | |
Issue #18214: Improve finalization of Python modules to avoid setting their globals to None, in most cases.
Diffstat (limited to 'Lib/test/test_module.py')
| -rw-r--r-- | Lib/test/test_module.py | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index b34b30f91a..3000cec55f 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -1,6 +1,7 @@  # Test the module type  import unittest  from test.support import run_unittest, gc_collect +from test.script_helper import assert_python_ok  import sys  ModuleType = type(sys) @@ -70,7 +71,6 @@ class ModuleTests(unittest.TestCase):                 "__loader__": None, "__package__": None})          self.assertTrue(foo.__dict__ is d) -    @unittest.expectedFailure      def test_dont_clear_dict(self):          # See issue 7140.          def f(): @@ -181,6 +181,19 @@ a = A(destroyed)"""          self.assertEqual(r[:25], "<module 'unittest' from '")          self.assertEqual(r[-13:], "__init__.py'>") +    def test_module_finalization_at_shutdown(self): +        # Module globals and builtins should still be available during shutdown +        rc, out, err = assert_python_ok("-c", "from test import final_a") +        self.assertFalse(err) +        lines = out.splitlines() +        self.assertEqual(set(lines), { +            b"x = a", +            b"x = b", +            b"final_a.x = a", +            b"final_b.x = b", +            b"len = len", +            b"shutil.rmtree = rmtree"}) +      # frozen and namespace module reprs are tested in importlib. | 
