Skip to content

Commit 63c9aa6

Browse files
[3.13] gh-148487: Fix issues in test_add_python_opts (#148507) (#148546)
gh-148487: Fix issues in `test_add_python_opts` (#148507) (cherry picked from commit 44f1b98) Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent ff88ee4 commit 63c9aa6

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Lib/test/test_regrtest.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,11 +2221,8 @@ def test_unload_tests(self):
22212221
self.check_executed_tests(output, tests, stats=3)
22222222

22232223
def check_add_python_opts(self, option):
2224-
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
2225-
try:
2226-
import _testinternalcapi
2227-
except ImportError:
2228-
raise unittest.SkipTest("requires _testinternalcapi")
2224+
# --fast-ci and --slow-ci add "-u -W error -bb -E" options to Python
2225+
22292226
code = textwrap.dedent(r"""
22302227
import sys
22312228
import unittest
@@ -2239,25 +2236,27 @@ def check_add_python_opts(self, option):
22392236
use_environment = (support.is_emscripten or support.is_wasi)
22402237
22412238
class WorkerTests(unittest.TestCase):
2242-
@unittest.skipUnless(get_config is None, 'need get_config()')
2239+
@unittest.skipIf(get_config is None, 'need get_config()')
22432240
def test_config(self):
2244-
config = get_config()['config']
2241+
config = get_config()
22452242
# -u option
22462243
self.assertEqual(config['buffered_stdio'], 0)
2247-
# -W default option
2248-
self.assertTrue(config['warnoptions'], ['default'])
2244+
# -W error option
2245+
self.assertEqual(config['warnoptions'],
2246+
['error', 'error::BytesWarning'])
22492247
# -bb option
2250-
self.assertTrue(config['bytes_warning'], 2)
2248+
self.assertEqual(config['bytes_warning'], 2)
22512249
# -E option
2252-
self.assertTrue(config['use_environment'], use_environment)
2250+
self.assertEqual(config['use_environment'], use_environment)
22532251
22542252
def test_python_opts(self):
22552253
# -u option
22562254
self.assertTrue(sys.__stdout__.write_through)
22572255
self.assertTrue(sys.__stderr__.write_through)
22582256
2259-
# -W default option
2260-
self.assertTrue(sys.warnoptions, ['default'])
2257+
# -W error option
2258+
self.assertEqual(sys.warnoptions,
2259+
['error', 'error::BytesWarning'])
22612260
22622261
# -bb option
22632262
self.assertEqual(sys.flags.bytes_warning, 2)

0 commit comments

Comments
 (0)