Skip to content

Commit d265a59

Browse files
committed
Update tests
1 parent 21d2e73 commit d265a59

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Lib/test/test_sysconfig.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ def test_always_set_py_gil_disabled(self):
611611
self.assertEqual(Py_GIL_DISABLED, support.Py_GIL_DISABLED)
612612

613613
def test_abiflags(self):
614-
# If this test fails on some platforms, maintainers should add/update
615-
# the definition of the ABIFLAGS variable and make this test pass.
614+
# If this test fails on some platforms, maintainers should update the
615+
# test to make it pass, rather than changing the definition of ABIFLAGS.
616616
abiflags = sysconfig.get_config_var('abiflags')
617617
ABIFLAGS = sysconfig.get_config_var('ABIFLAGS')
618618

@@ -621,21 +621,23 @@ def test_abiflags(self):
621621
self.assertIn(abiflags, ABIFLAGS)
622622

623623
# Check all flags are alphabetic
624+
valid_abiflags = ('', 't', 'd', 'td')
625+
for flags in valid_abiflags:
626+
self.assertTrue(len(flags) == len(set(flags)), flags)
627+
if flags:
628+
self.assertIn(flags.isalpha(), flags)
624629
if os.name == 'nt':
625630
self.assertEqual(abiflags, '')
626631
# Example values: '', 't', 't_d', '_d'
627632
# '_' can only exist if 'd' is present
628-
if '_' in ABIFLAGS:
629-
# '_' is followed by 'd'
630-
self.assertTrue(ABIFLAGS.count('_d') == 1, ABIFLAGS)
631-
self.assertTrue(ABIFLAGS.count('_') == 1, ABIFLAGS)
632-
else:
633-
self.assertNotIn('d', ABIFLAGS)
633+
# '_' can only followed by 'd'
634+
self.assertIn(
635+
ABIFLAGS,
636+
tuple(flag.replace('d', '_d') for flag in valid_abiflags),
637+
)
634638
else:
635639
# Example values: '', 't', 'td', 'd'
636-
self.assertNotIn('_', ABIFLAGS)
637-
if ABIFLAGS:
638-
self.assertTrue(ABIFLAGS.replace('_', '').isalpha(), ABIFLAGS)
640+
self.assertIn(ABIFLAGS, valid_abiflags)
639641

640642
if support.Py_DEBUG:
641643
# The 'd' flag should always be the last one.

0 commit comments

Comments
 (0)