[3.7] bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095) by miss-islington · Pull Request #20110 · python/cpython
here = os.path.dirname(__file__) or os.curdir
def test_suite(): old_filters = warnings.filters[:] suite = unittest.TestSuite() for fn in os.listdir(here): if fn.startswith("test") and fn.endswith(".py"): modname = "distutils.tests." + fn[:-3] __import__(modname) module = sys.modules[modname] suite.addTest(module.test_suite()) # bpo-40055: Save/restore warnings filters to leave them unchanged. # Importing tests imports docutils which imports pkg_resources which adds a # warnings filter. warnings.filters[:] = old_filters return suite