]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95349: Hide a Distutils Warning Filter for test_check_c_globals (GH-95837)
authorEric Snow <ericsnowcurrently@gmail.com>
Tue, 9 Aug 2022 23:04:05 +0000 (17:04 -0600)
committerGitHub <noreply@github.com>
Tue, 9 Aug 2022 23:04:05 +0000 (16:04 -0700)
Under certain build conditions, test_check_c_globals fails.  This fix takes the same approach as we took for gh-84236 (via gh-20095).  We'll be removing use of distutils in the c-analyzer at some point.  Until then we'll hide the warning filter.

Lib/test/test_check_c_globals.py

index 030debc452e40924c3640d218f4e6121f116e3f0..898807a5e69259e7d33e2c4653866ac5319ee07d 100644 (file)
@@ -1,9 +1,14 @@
 import unittest
 import test.test_tools
+from test.support.warnings_helper import save_restore_warnings_filters
 
 test.test_tools.skip_if_missing('c-analyzer')
 with test.test_tools.imports_under_tool('c-analyzer'):
-    from cpython.__main__ import main
+    # gh-95349: Save/restore warnings filters to leave them unchanged.
+    # Importing the c-analyzer imports docutils which imports pkg_resources
+    # which adds a warnings filter.
+    with save_restore_warnings_filters():
+        from cpython.__main__ import main
 
 
 class ActualChecks(unittest.TestCase):