Skip to content

Commit

Permalink
bpo-40055: test_distutils leaves warnings filters unchanged (pythonGH…
Browse files Browse the repository at this point in the history
…-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.
  • Loading branch information
vstinner committed May 15, 2020
1 parent 003708b commit 6e57237
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/distutils/tests/__init__.py
Expand Up @@ -15,20 +15,26 @@
import os
import sys
import unittest
import warnings
from test.support import run_unittest


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


Expand Down
@@ -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.

0 comments on commit 6e57237

Please sign in to comment.