]> granicus.if.org Git - python/commitdiff
The test that calls a function with invalid arguments and catches the
authorThomas Heller <theller@ctypes.org>
Thu, 6 Jul 2006 08:28:14 +0000 (08:28 +0000)
committerThomas Heller <theller@ctypes.org>
Thu, 6 Jul 2006 08:28:14 +0000 (08:28 +0000)
resulting Windows access violation will not be run by default.

Lib/ctypes/test/test_win32.py

index 8247d370d39b2198a3a47aa59b5dff39dc0cbaac..db530d3af4ad4392b20742387d49f8cafa0245fa 100644 (file)
@@ -1,6 +1,7 @@
 # Windows specific tests
 
 from ctypes import *
+from ctypes.test import is_resource_enabled
 import unittest, sys
 
 import _ctypes_test
@@ -30,15 +31,10 @@ if sys.platform == "win32":
             # or wrong calling convention
             self.assertRaises(ValueError, IsWindow, None)
 
-        def test_SEH(self):
-            # Call functions with invalid arguments, and make sure that access violations
-            # are trapped and raise an exception.
-            #
-            # Normally, in a debug build of the _ctypes extension
-            # module, exceptions are not trapped, so we can only run
-            # this test in a release build.
-            import sys
-            if not hasattr(sys, "getobjects"):
+        if is_resource_enabled("SEH"):
+            def test_SEH(self):
+                # Call functions with invalid arguments, and make sure that access violations
+                # are trapped and raise an exception.
                 self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
 
 class Structures(unittest.TestCase):