]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-148487: Fix issues in `test_add_python_opts` (#148507) (#148546)
authorVictor Stinner <vstinner@python.org>
Tue, 14 Apr 2026 10:08:32 +0000 (12:08 +0200)
committerGitHub <noreply@github.com>
Tue, 14 Apr 2026 10:08:32 +0000 (10:08 +0000)
gh-148487: Fix issues in `test_add_python_opts` (#148507)

(cherry picked from commit 44f1b987ed1908185d8021fd31703b2dd4d97e82)

Co-authored-by: Stan Ulbrych <stan@python.org>
Lib/test/test_regrtest.py

index 8e1f85090753cb4e048306294bbb6f66eb049a2f..9206425d997ee5dc8b3734486c880b758b5fb4cb 100644 (file)
@@ -2221,11 +2221,8 @@ class ArgsTestCase(BaseTestCase):
         self.check_executed_tests(output, tests, stats=3)
 
     def check_add_python_opts(self, option):
-        # --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
-        try:
-            import _testinternalcapi
-        except ImportError:
-            raise unittest.SkipTest("requires _testinternalcapi")
+        # --fast-ci and --slow-ci add "-u -W error -bb -E" options to Python
+
         code = textwrap.dedent(r"""
             import sys
             import unittest
@@ -2239,25 +2236,27 @@ class ArgsTestCase(BaseTestCase):
             use_environment = (support.is_emscripten or support.is_wasi)
 
             class WorkerTests(unittest.TestCase):
-                @unittest.skipUnless(get_config is None, 'need get_config()')
+                @unittest.skipIf(get_config is None, 'need get_config()')
                 def test_config(self):
-                    config = get_config()['config']
+                    config = get_config()
                     # -u option
                     self.assertEqual(config['buffered_stdio'], 0)
-                    # -W default option
-                    self.assertTrue(config['warnoptions'], ['default'])
+                    # -W error option
+                    self.assertEqual(config['warnoptions'],
+                                     ['error', 'error::BytesWarning'])
                     # -bb option
-                    self.assertTrue(config['bytes_warning'], 2)
+                    self.assertEqual(config['bytes_warning'], 2)
                     # -E option
-                    self.assertTrue(config['use_environment'], use_environment)
+                    self.assertEqual(config['use_environment'], use_environment)
 
                 def test_python_opts(self):
                     # -u option
                     self.assertTrue(sys.__stdout__.write_through)
                     self.assertTrue(sys.__stderr__.write_through)
 
-                    # -W default option
-                    self.assertTrue(sys.warnoptions, ['default'])
+                    # -W error option
+                    self.assertEqual(sys.warnoptions,
+                                     ['error', 'error::BytesWarning'])
 
                     # -bb option
                     self.assertEqual(sys.flags.bytes_warning, 2)