diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-05-15 16:25:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-15 16:25:00 (GMT) |
commit | 4e6545b002dd4d068b2538ffca60830d0e7fd369 (patch) | |
tree | c1a724746718e4353ca5952df1720073172e3db5 | |
parent | 07bd5cf3d9551ae84100e6400836163fcd507f07 (diff) | |
download | cpython-4e6545b002dd4d068b2538ffca60830d0e7fd369.zip cpython-4e6545b002dd4d068b2538ffca60830d0e7fd369.tar.gz cpython-4e6545b002dd4d068b2538ffca60830d0e7fd369.tar.bz2 |
bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
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>
-rw-r--r-- | Lib/distutils/tests/__init__.py | 6 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2020-05-15-01-21-44.bpo-40055.Xp4aP9.rst | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Lib/distutils/tests/__init__.py b/Lib/distutils/tests/__init__.py index 1b939cb..5d2e69e 100644 --- a/Lib/distutils/tests/__init__.py +++ b/Lib/distutils/tests/__init__.py @@ -15,6 +15,7 @@ by import rather than matching pre-defined names. import os import sys import unittest +import warnings from test.support import run_unittest @@ -22,6 +23,7 @@ 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"): @@ -29,6 +31,10 @@ def test_suite(): __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 diff --git a/Misc/NEWS.d/next/Tests/2020-05-15-01-21-44.bpo-40055.Xp4aP9.rst b/Misc/NEWS.d/next/Tests/2020-05-15-01-21-44.bpo-40055.Xp4aP9.rst new file mode 100644 index 0000000..edb0118 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-05-15-01-21-44.bpo-40055.Xp4aP9.rst @@ -0,0 +1,3 @@ +distutils.tests now saves/restores warnings filters to leave them unchanged. +Importing tests imports docutils which imports pkg_resources which adds a +warnings filter. |