Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7180c79

Browse files
committed
Issue #21829: Fix running test_ctypes on Windows with -O or -OO
1 parent c6772c4 commit 7180c79

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

Lib/ctypes/test/test_values.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,11 @@ class Win_ValuesTestCase(unittest.TestCase):
3333
"""This test only works when python itself is a dll/shared library"""
3434

3535
def test_optimizeflag(self):
36-
# This test accesses the Py_OptimizeFlag intger, which is
37-
# exported by the Python dll.
36+
# This test accesses the Py_OptimizeFlag integer, which is
37+
# exported by the Python dll and should match the sys.flags value
3838

39-
# It's value is set depending on the -O and -OO flags:
40-
# if not given, it is 0 and __debug__ is 1.
41-
# If -O is given, the flag is 1, for -OO it is 2.
42-
# docstrings are also removed in the latter case.
4339
opt = c_int.in_dll(pythonapi, "Py_OptimizeFlag").value
44-
if __debug__:
45-
self.assertEqual(opt, 0)
46-
elif ValuesTestCase.__doc__ is not None:
47-
self.assertEqual(opt, 1)
48-
else:
49-
self.assertEqual(opt, 2)
40+
self.assertEqual(opt, sys.flags.optimize)
5041

5142
def test_frozentable(self):
5243
# Python exports a PyImport_FrozenModules symbol. This is a

0 commit comments

Comments
 (0)