Skip to content

Commit

Permalink
bpo-40055: test_distutils leaves warnings filters unchanged (GH-20095)
Browse files Browse the repository at this point in the history
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 6e57237)

Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
miss-islington and vstinner authored May 15, 2020
1 parent 07bd5cf commit 4e6545b
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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 4e6545b

Please sign in to comment.