summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-15 16:06:23 (GMT)
committerGitHub <noreply@github.com>2020-05-15 16:06:23 (GMT)
commit6e57237faf0da8904e0130a11350cae3c5062b82 (patch)
treed5fcadc48c30c7db5b9e2e2a9699c2b794c94f51 /Lib/distutils/tests
parent003708bcf8f2c58d4b65f68318acf164d713e008 (diff)
downloadcpython-6e57237faf0da8904e0130a11350cae3c5062b82.zip
cpython-6e57237faf0da8904e0130a11350cae3c5062b82.tar.gz
cpython-6e57237faf0da8904e0130a11350cae3c5062b82.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.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/__init__.py6
1 files changed, 6 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