]> granicus.if.org Git - python/commitdiff
Issue #21499: Ignore __builtins__ in several test_importlib.test_api tests.
authorEric Snow <ericsnowcurrently@gmail.com>
Tue, 13 May 2014 18:15:42 +0000 (12:15 -0600)
committerEric Snow <ericsnowcurrently@gmail.com>
Tue, 13 May 2014 18:15:42 +0000 (12:15 -0600)
Lib/test/test_importlib/test_api.py
Misc/NEWS

index 744001b4c0580f357f5565fb7d6e698e96220bca..2a2d42bbfe7b54a71882dd4d8bc33760157846d1 100644 (file)
@@ -241,13 +241,13 @@ class ReloadTests:
                                 '__file__': path,
                                 '__cached__': cached,
                                 '__doc__': None,
-                                '__builtins__': __builtins__,
                                 }
                     support.create_empty_file(path)
                     module = self.init.import_module(name)
-                    ns = vars(module)
+                    ns = vars(module).copy()
                     loader = ns.pop('__loader__')
                     spec = ns.pop('__spec__')
+                    ns.pop('__builtins__', None)  # An implementation detail.
                     self.assertEqual(spec.name, name)
                     self.assertEqual(spec.loader, loader)
                     self.assertEqual(loader.path, path)
@@ -263,14 +263,14 @@ class ReloadTests:
                                 '__cached__': cached,
                                 '__path__': [os.path.dirname(init_path)],
                                 '__doc__': None,
-                                '__builtins__': __builtins__,
                                 }
                     os.mkdir(name)
                     os.rename(path, init_path)
                     reloaded = self.init.reload(module)
-                    ns = vars(reloaded)
+                    ns = vars(reloaded).copy()
                     loader = ns.pop('__loader__')
                     spec = ns.pop('__spec__')
+                    ns.pop('__builtins__', None)  # An implementation detail.
                     self.assertEqual(spec.name, name)
                     self.assertEqual(spec.loader, loader)
                     self.assertIs(reloaded, module)
@@ -295,10 +295,11 @@ class ReloadTests:
                     with open(bad_path, 'w') as init_file:
                         init_file.write('eggs = None')
                     module = self.init.import_module(name)
-                    ns = vars(module)
+                    ns = vars(module).copy()
                     loader = ns.pop('__loader__')
                     path = ns.pop('__path__')
                     spec = ns.pop('__spec__')
+                    ns.pop('__builtins__', None)  # An implementation detail.
                     self.assertEqual(spec.name, name)
                     self.assertIs(spec.loader, None)
                     self.assertIsNot(loader, None)
@@ -319,14 +320,14 @@ class ReloadTests:
                                 '__cached__': cached,
                                 '__path__': [os.path.dirname(init_path)],
                                 '__doc__': None,
-                                '__builtins__': __builtins__,
                                 'eggs': None,
                                 }
                     os.rename(bad_path, init_path)
                     reloaded = self.init.reload(module)
-                    ns = vars(reloaded)
+                    ns = vars(reloaded).copy()
                     loader = ns.pop('__loader__')
                     spec = ns.pop('__spec__')
+                    ns.pop('__builtins__', None)  # An implementation detail.
                     self.assertEqual(spec.name, name)
                     self.assertEqual(spec.loader, loader)
                     self.assertIs(reloaded, module)
index 72204aab022d884df14ec2e9708c79dcb6cf3bc3..f85155e0bc3a5e013c057bda610c88bb0d248de4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -187,6 +187,8 @@ Library
 
 - Issue #20884: Don't assume that __file__ is defined on importlib.__init__.
 
+- Issue #21499: Ignore __builtins__ in several test_importlib.test_api tests.
+
 - Issue #20879: Delay the initialization of encoding and decoding tables for
   base32, ascii85 and base85 codecs in the base64 module, and delay the
   initialization of the unquote_to_bytes() table of the urllib.parse module, to