Kaydet (Commit) ed52f6cb authored tarafından Ezio Melotti's avatar Ezio Melotti

#11078: test___all__ now checks for duplicates in __all__. Initial patch by R. David Murray.

üst 4c09c2cb
...@@ -29,17 +29,20 @@ class AllTest(unittest.TestCase): ...@@ -29,17 +29,20 @@ class AllTest(unittest.TestCase):
if not hasattr(sys.modules[modname], "__all__"): if not hasattr(sys.modules[modname], "__all__"):
raise NoAll(modname) raise NoAll(modname)
names = {} names = {}
try: with self.subTest(module=modname):
exec("from %s import *" % modname, names) try:
except Exception as e: exec("from %s import *" % modname, names)
# Include the module name in the exception string except Exception as e:
self.fail("__all__ failure in {}: {}: {}".format( # Include the module name in the exception string
modname, e.__class__.__name__, e)) self.fail("__all__ failure in {}: {}: {}".format(
if "__builtins__" in names: modname, e.__class__.__name__, e))
del names["__builtins__"] if "__builtins__" in names:
keys = set(names) del names["__builtins__"]
all = set(sys.modules[modname].__all__) keys = set(names)
self.assertEqual(keys, all) all_list = sys.modules[modname].__all__
all_set = set(all_list)
self.assertCountEqual(all_set, all_list, "in module {}".format(modname))
self.assertEqual(keys, all_set, "in module {}".format(modname))
def walk_modules(self, basedir, modpath): def walk_modules(self, basedir, modpath):
for fn in sorted(os.listdir(basedir)): for fn in sorted(os.listdir(basedir)):
......
...@@ -176,6 +176,9 @@ Library ...@@ -176,6 +176,9 @@ Library
Tests Tests
----- -----
- Issue #11078: test___all__ now checks for duplicates in __all__.
Initial patch by R. David Murray.
- Issue #17712: Fix test_gdb failures on Ubuntu 13.04. - Issue #17712: Fix test_gdb failures on Ubuntu 13.04.
- Issue #17835: Fix test_io when the default OS pipe buffer size is larger - Issue #17835: Fix test_io when the default OS pipe buffer size is larger
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment