distutils.tests now saves/restores warnings filters to leave them
unchanged. Importing tests imports docutils which imports
pkg_resources which adds a warnings filter.
(cherry picked from commit
6e57237faf0da8904e0130a11350cae3c5062b82)
Co-authored-by: Victor Stinner <vstinner@python.org>
import os
import sys
import unittest
+import warnings
from test.support import run_unittest
def test_suite():
+ old_filters = warnings.filters[:]
suite = unittest.TestSuite()
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
__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
--- /dev/null
+distutils.tests now saves/restores warnings filters to leave them unchanged.
+Importing tests imports docutils which imports pkg_resources which adds a
+warnings filter.