def METHOD_NAME(self, modname):
    names = {}
    with support.check_warnings(
        (".* (module|package)", DeprecationWarning),
        ("", ResourceWarning),
        quiet=True):
        try:
            exec("import %s" % modname, names)
        except:
            # Silent fail here seems the best route since some modules
            # may not be available or not initialize properly in all
            # environments.
            raise FailedImport(modname)
    if not hasattr(sys.modules[modname], "__all__"):
        raise NoAll(modname)
    names = {}
    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))