Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e6545b

Browse filesBrowse files
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 6e57237) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 07bd5cf commit 4e6545b
Copy full SHA for 4e6545b

File tree

2 files changed

+9
-0
lines changed
Filter options

2 files changed

+9
-0
lines changed

‎Lib/distutils/tests/__init__.py

Copy file name to clipboardExpand all lines: Lib/distutils/tests/__init__.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@
1515
import os
1616
import sys
1717
import unittest
18+
import warnings
1819
from test.support import run_unittest
1920

2021

2122
here = os.path.dirname(__file__) or os.curdir
2223

2324

2425
def test_suite():
26+
old_filters = warnings.filters[:]
2527
suite = unittest.TestSuite()
2628
for fn in os.listdir(here):
2729
if fn.startswith("test") and fn.endswith(".py"):
2830
modname = "distutils.tests." + fn[:-3]
2931
__import__(modname)
3032
module = sys.modules[modname]
3133
suite.addTest(module.test_suite())
34+
# bpo-40055: Save/restore warnings filters to leave them unchanged.
35+
# Importing tests imports docutils which imports pkg_resources which adds a
36+
# warnings filter.
37+
warnings.filters[:] = old_filters
3238
return suite
3339

3440

+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
distutils.tests now saves/restores warnings filters to leave them unchanged.
2+
Importing tests imports docutils which imports pkg_resources which adds a
3+
warnings filter.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.