From 10f29c903751f80c3f53be433dcbbba6f1382048 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Thu, 20 Oct 2016 07:44:29 +0000 Subject: [PATCH 1/2] Issue #28471: Avoid ResourceWarning by detaching test socket --- Lib/test/test_socket.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 0cf7bfe2939..a56d8a4101a 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -4559,6 +4559,7 @@ class TestExceptions(unittest.TestCase): sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM, 0, sock0.fileno()) sock0.close() + self.addCleanup(sock.detach) with self.assertRaises(OSError): sock.setblocking(False) From 56b2cf5e8564c7221a42675d35aaa0d0c503365e Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Thu, 20 Oct 2016 21:45:49 +0000 Subject: [PATCH 2/2] Issue #28484: Skip tests if GIL is not used or multithreading is disabled --- Lib/test/test_capi.py | 1 + Lib/test/test_regrtest.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 5521e761121..d4faeb375e4 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -630,6 +630,7 @@ class PyMemDebugTests(unittest.TestCase): regex = regex.format(ptr=self.PTR_REGEX) self.assertRegex(out, regex) + @unittest.skipUnless(threading, 'Test requires a GIL (multithreading)') def check_malloc_without_gil(self, code): out = self.check(code) expected = ('Fatal Python error: Python memory allocator called ' diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index d43160470f2..52909d833e7 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -696,7 +696,12 @@ class ArgsTestCase(BaseTestCase): code = TEST_INTERRUPTED test = self.create_test("sigint", code=code) - for multiprocessing in (False, True): + try: + import threading + tests = (False, True) + except ImportError: + tests = (False,) + for multiprocessing in tests: if multiprocessing: args = ("--slowest", "-j2", test) else: