summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-05-15 18:06:23 +0200
committerGitHub <noreply@github.com>2020-05-15 18:06:23 +0200
commitb9d48323ce2571376ba34c05d65450f66e1581e9 (patch)
tree3f3adef68dde9118eadc9624850b7332e038b430
parenta672328f1e2515f5b103df12d19fa3c2ffba68fc (diff)
downloadpython-setuptools-git-b9d48323ce2571376ba34c05d65450f66e1581e9.tar.gz
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.
-rw-r--r--tests/__init__.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 1b939cbd..5d2e69e3 100644
--- a/tests/__init__.py
+++ b/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