diff options
Diffstat (limited to 'Lib/test/test___all__.py')
| -rw-r--r-- | Lib/test/test___all__.py | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 608ec01..e94d984 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -29,17 +29,20 @@ class AllTest(unittest.TestCase): if not hasattr(sys.modules[modname], "__all__"): raise NoAll(modname) names = {} - try: - exec("from %s import *" % modname, names) - except Exception as e: - # Include the module name in the exception string - self.fail("__all__ failure in {}: {}: {}".format( - modname, e.__class__.__name__, e)) - if "__builtins__" in names: - del names["__builtins__"] - keys = set(names) - all = set(sys.modules[modname].__all__) - self.assertEqual(keys, all) + with self.subTest(module=modname): + try: + exec("from %s import *" % modname, names) + except Exception as e: + # Include the module name in the exception string + self.fail("__all__ failure in {}: {}: {}".format( + modname, e.__class__.__name__, e)) + if "__builtins__" in names: + del names["__builtins__"] + keys = set(names) + 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): for fn in sorted(os.listdir(basedir)): @@ -69,13 +72,14 @@ class AllTest(unittest.TestCase): # rlcompleter needs special consideration; it import readline which # initializes GNU readline which calls setlocale(LC_CTYPE, "")... :-( + import locale + locale_tuple = locale.getlocale(locale.LC_CTYPE) try: import rlcompleter - import locale except ImportError: pass - else: - locale.setlocale(locale.LC_CTYPE, 'C') + finally: + locale.setlocale(locale.LC_CTYPE, locale_tuple) ignored = [] failed_imports = [] @@ -110,8 +114,5 @@ class AllTest(unittest.TestCase): print('Following modules failed to be imported:', failed_imports) -def test_main(): - support.run_unittest(AllTest) - if __name__ == "__main__": - test_main() + unittest.main() |
