]> granicus.if.org Git - python/commitdiff
Better reporting of test failures on Windows.
authorBrian Quinlan <brian@sweetapp.com>
Fri, 24 Dec 2010 23:10:41 +0000 (23:10 +0000)
committerBrian Quinlan <brian@sweetapp.com>
Fri, 24 Dec 2010 23:10:41 +0000 (23:10 +0000)
Lib/test/test_concurrent_futures.py

index e4e38ec93fe7856c9d0ead674098d1624680b136..7baf0a275a71f061a2c96c0ca6a19b90f2c05cba 100644 (file)
@@ -75,15 +75,27 @@ class Call(object):
 
     def _wait_on_event(self, handle):
         if sys.platform.startswith('win'):
+            # WaitForSingleObject returns 0 if handle is signaled.
             r = ctypes.windll.kernel32.WaitForSingleObject(handle, 60 * 1000)
-            assert r == 0
+            if r != 0:
+                message = (
+                    'WaitForSingleObject({}, ...) failed with {}, '
+                    'GetLastError() = {}'.format(
+                            handle, r, ctypes.GetLastError()))
+                logging.critical(message)
+                assert False, message
         else:
             self.CALL_LOCKS[handle].wait()
 
     def _signal_event(self, handle):
         if sys.platform.startswith('win'):
-            r = ctypes.windll.kernel32.SetEvent(handle)
-            assert r != 0
+            r = ctypes.windll.kernel32.SetEvent(handle)  # Returns 0 on failure.
+            if r == 0:
+                message = (
+                    'SetEvent({}) failed with {}, GetLastError() = {}'.format(
+                            handle, r, ctypes.GetLastError()))
+                logging.critical(message)
+                assert False, message
         else:
             self.CALL_LOCKS[handle].set()