]> granicus.if.org Git - python/commitdiff
Issue #21829: Fix running test_ctypes on Windows with -O or -OO
authorZachary Ware <zachary.ware@gmail.com>
Thu, 26 Jun 2014 20:20:44 +0000 (15:20 -0500)
committerZachary Ware <zachary.ware@gmail.com>
Thu, 26 Jun 2014 20:20:44 +0000 (15:20 -0500)
Lib/ctypes/test/test_values.py

index ae9f5629a67646e638500040c083f68ce5749d91..1c1fd7dbb61ff5f65b5d6cd8aed734416dee173b 100644 (file)
@@ -33,20 +33,11 @@ class Win_ValuesTestCase(unittest.TestCase):
     """This test only works when python itself is a dll/shared library"""
 
     def test_optimizeflag(self):
-        # This test accesses the Py_OptimizeFlag intger, which is
-        # exported by the Python dll.
+        # This test accesses the Py_OptimizeFlag integer, which is
+        # exported by the Python dll and should match the sys.flags value
 
-        # It's value is set depending on the -O and -OO flags:
-        # if not given, it is 0 and __debug__ is 1.
-        # If -O is given, the flag is 1, for -OO it is 2.
-        # docstrings are also removed in the latter case.
         opt = c_int.in_dll(pythonapi, "Py_OptimizeFlag").value
-        if __debug__:
-            self.assertEqual(opt, 0)
-        elif ValuesTestCase.__doc__ is not None:
-            self.assertEqual(opt, 1)
-        else:
-            self.assertEqual(opt, 2)
+        self.assertEqual(opt, sys.flags.optimize)
 
     def test_frozentable(self):
         # Python exports a PyImport_FrozenModules symbol. This is a