summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-08-18 21:47:54 (GMT)
committerGitHub <noreply@github.com>2017-08-18 21:47:54 (GMT)
commit6966960468327c958b03391f71f24986bd697307 (patch)
treef9bde4ec810d3efc9f3000ccc5f430b0a0eaa3d9
parent93d0cb58b4da2a88c56f472c6c19491cc7a390df (diff)
downloadcpython-6966960468327c958b03391f71f24986bd697307.zip
cpython-6966960468327c958b03391f71f24986bd697307.tar.gz
cpython-6966960468327c958b03391f71f24986bd697307.tar.bz2
bpo-30830: test_logging uses threading_setup/cleanup (#3137)
* bpo-30830: test_logging uses threading_setup/cleanup Replace @support.reap_threads on some methods with support.threading_setup() in setUp() and support.threading_cleanup() in tearDown() in BaseTest. * bpo-30830: test_logging disables threaded socketserver tests Disable tests because of socketserver.ThreadingMixIn leaks threads, whereas leaking threads now makes a test to fail on buildbots. Disable tests until socketserver is fixed: bpo-31233. * Skip also setup_via_listener()
-rw-r--r--Lib/test/test_logging.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index a91cfd4..226532a 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -79,6 +79,8 @@ class BaseTest(unittest.TestCase):
def setUp(self):
"""Setup the default logging stream to an internal StringIO instance,
so that we can examine log output as we want."""
+ self._threading_key = support.threading_setup()
+
logger_dict = logging.getLogger().manager.loggerDict
logging._acquireLock()
try:
@@ -147,6 +149,9 @@ class BaseTest(unittest.TestCase):
finally:
logging._releaseLock()
+ self.doCleanups()
+ support.threading_cleanup(*self._threading_key)
+
def assert_log_lines(self, expected_values, stream=None, pat=None):
"""Match the collected log lines against the regular expression
self.expected_log_pat, and compare the extracted group values to
@@ -621,7 +626,6 @@ class HandlerTest(BaseTest):
@unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
@unittest.skipUnless(threading, 'Threading required for this test.')
- @support.reap_threads
def test_race(self):
# Issue #14632 refers.
def remove_loop(fname, tries):
@@ -986,7 +990,6 @@ if threading:
class SMTPHandlerTest(BaseTest):
TIMEOUT = 8.0
- @support.reap_threads
def test_basic(self):
sockmap = {}
server = TestSMTPServer((support.HOST, 0), self.process_message, 0.001,
@@ -1466,6 +1469,7 @@ class ConfigFileTest(BaseTest):
self.assertFalse(logger.disabled)
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(threading, 'Threading required for this test.')
class SocketHandlerTest(BaseTest):
@@ -1565,6 +1569,7 @@ def _get_temp_domain_socket():
os.remove(fn)
return fn
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
@unittest.skipUnless(threading, 'Threading required for this test.')
class UnixSocketHandlerTest(SocketHandlerTest):
@@ -1583,6 +1588,7 @@ class UnixSocketHandlerTest(SocketHandlerTest):
SocketHandlerTest.tearDown(self)
support.unlink(self.address)
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(threading, 'Threading required for this test.')
class DatagramHandlerTest(BaseTest):
@@ -1649,6 +1655,7 @@ class DatagramHandlerTest(BaseTest):
self.handled.wait()
self.assertEqual(self.log_output, "spam\neggs\n")
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
@unittest.skipUnless(threading, 'Threading required for this test.')
class UnixDatagramHandlerTest(DatagramHandlerTest):
@@ -1736,6 +1743,7 @@ class SysLogHandlerTest(BaseTest):
self.handled.wait()
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
@unittest.skipUnless(threading, 'Threading required for this test.')
class UnixSysLogHandlerTest(SysLogHandlerTest):
@@ -1754,6 +1762,7 @@ class UnixSysLogHandlerTest(SysLogHandlerTest):
SysLogHandlerTest.tearDown(self)
support.unlink(self.address)
+@unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(support.IPV6_ENABLED,
'IPv6 support required for this test.')
@unittest.skipUnless(threading, 'Threading required for this test.')
@@ -1795,7 +1804,6 @@ class HTTPHandlerTest(BaseTest):
request.end_headers()
self.handled.set()
- @support.reap_threads
def test_output(self):
# The log message sent to the HTTPHandler is properly received.
logger = logging.getLogger("http")
@@ -2879,6 +2887,9 @@ class ConfigDictTest(BaseTest):
logging.warning('Exclamation')
self.assertTrue(output.getvalue().endswith('Exclamation!\n'))
+ # listen() uses ConfigSocketReceiver which is based
+ # on socketserver.ThreadingTCPServer
+ @unittest.skipIf(True, "FIXME: bpo-30830")
@unittest.skipUnless(threading, 'listen() needs threading to work')
def setup_via_listener(self, text, verify=None):
text = text.encode("utf-8")
@@ -2911,7 +2922,6 @@ class ConfigDictTest(BaseTest):
self.fail("join() timed out")
@unittest.skipUnless(threading, 'Threading required for this test.')
- @support.reap_threads
def test_listen_config_10_ok(self):
with support.captured_stdout() as output:
self.setup_via_listener(json.dumps(self.config10))
@@ -2932,7 +2942,6 @@ class ConfigDictTest(BaseTest):
], stream=output)
@unittest.skipUnless(threading, 'Threading required for this test.')
- @support.reap_threads
def test_listen_config_1_ok(self):
with support.captured_stdout() as output:
self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1))
@@ -2948,7 +2957,6 @@ class ConfigDictTest(BaseTest):
self.assert_log_lines([])
@unittest.skipUnless(threading, 'Threading required for this test.')
- @support.reap_threads
def test_listen_verify(self):
def verify_fail(stuff):
@@ -3232,7 +3240,6 @@ if hasattr(logging.handlers, 'QueueListener'):
handler.close()
@patch.object(logging.handlers.QueueListener, 'handle')
- @support.reap_threads
def test_handle_called_with_queue_queue(self, mock_handle):
for i in range(self.repeat):
log_queue = queue.Queue()
@@ -3242,7 +3249,6 @@ if hasattr(logging.handlers, 'QueueListener'):
@support.requires_multiprocessing_queue
@patch.object(logging.handlers.QueueListener, 'handle')
- @support.reap_threads
def test_handle_called_with_mp_queue(self, mock_handle):
for i in range(self.repeat):
log_queue = multiprocessing.Queue()
@@ -3261,7 +3267,6 @@ if hasattr(logging.handlers, 'QueueListener'):
return []
@support.requires_multiprocessing_queue
- @support.reap_threads
def test_no_messages_in_queue_after_stop(self):
"""
Five messages are logged then the QueueListener is stopped. This