Commit 13623662 authored by Nick Coghlan's avatar Nick Coghlan

Try to turn some buildbots green by allowing test_multiprocessing to pass even...

Try to turn some buildbots green by allowing test_multiprocessing to pass even if it hits the sys.exc_clear code in the threading module, and improve the test coverage by making the ctypes dependencies a bit more granular (two of the cited ctypes objects don't exist on my system)
parent 9352f1c6
...@@ -13,7 +13,6 @@ import os ...@@ -13,7 +13,6 @@ import os
import gc import gc
import signal import signal
import array import array
import copy
import socket import socket
import random import random
import logging import logging
...@@ -67,11 +66,21 @@ WIN32 = (sys.platform == "win32") ...@@ -67,11 +66,21 @@ WIN32 = (sys.platform == "win32")
# #
try: try:
from ctypes import Structure, Value, copy, c_int, c_double from ctypes import Structure, c_int, c_double
except ImportError: except ImportError:
Structure = object Structure = object
c_int = c_double = None c_int = c_double = None
try:
from ctypes import Value
except ImportError:
Value = None
try:
from ctypes import copy as ctypes_copy
except ImportError:
ctypes_copy = None
# #
# Creates a wrapper for a function which records the time it takes to finish # Creates a wrapper for a function which records the time it takes to finish
# #
...@@ -1596,7 +1605,7 @@ class _TestSharedCTypes(BaseTestCase): ...@@ -1596,7 +1605,7 @@ class _TestSharedCTypes(BaseTestCase):
for i in range(len(arr)): for i in range(len(arr)):
arr[i] *= 2 arr[i] *= 2
@unittest.skipIf(c_int is None, "requires _ctypes") @unittest.skipIf(Value is None, "requires ctypes.Value")
def test_sharedctypes(self, lock=False): def test_sharedctypes(self, lock=False):
x = Value('i', 7, lock=lock) x = Value('i', 7, lock=lock)
y = Value(c_double, 1.0/3.0, lock=lock) y = Value(c_double, 1.0/3.0, lock=lock)
...@@ -1617,13 +1626,14 @@ class _TestSharedCTypes(BaseTestCase): ...@@ -1617,13 +1626,14 @@ class _TestSharedCTypes(BaseTestCase):
self.assertAlmostEqual(arr[i], i*2) self.assertAlmostEqual(arr[i], i*2)
self.assertEqual(string.value, latin('hellohello')) self.assertEqual(string.value, latin('hellohello'))
@unittest.skipIf(Value is None, "requires ctypes.Value")
def test_synchronize(self): def test_synchronize(self):
self.test_sharedctypes(lock=True) self.test_sharedctypes(lock=True)
@unittest.skipIf(c_int is None, "requires _ctypes") @unittest.skipIf(ctypes_copy is None, "requires ctypes.copy")
def test_copy(self): def test_copy(self):
foo = _Foo(2, 5.0) foo = _Foo(2, 5.0)
bar = copy(foo) bar = ctypes_copy(foo)
foo.x = 0 foo.x = 0
foo.y = 0 foo.y = 0
self.assertEqual(bar.x, 2) self.assertEqual(bar.x, 2)
...@@ -2025,8 +2035,14 @@ def test_main(run=None): ...@@ -2025,8 +2035,14 @@ def test_main(run=None):
loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase
suite = unittest.TestSuite(loadTestsFromTestCase(tc) for tc in testcases) suite = unittest.TestSuite(loadTestsFromTestCase(tc) for tc in testcases)
# (ncoghlan): Whether or not sys.exc_clear is executed by the threading
# module during these tests is at least platform dependent and possibly
# non-deterministic on any given platform. So we don't find if the listed
# warnings aren't actually raised.
with test_support.check_py3k_warnings( with test_support.check_py3k_warnings(
(".+__(get|set)slice__ has been removed", DeprecationWarning)): (".+__(get|set)slice__ has been removed", DeprecationWarning),
(r"sys.exc_clear\(\) not supported", DeprecationWarning),
quiet=True):
run(suite) run(suite)
ThreadsMixin.pool.terminate() ThreadsMixin.pool.terminate()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment