mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Issue #21636: Fix test_logging, skip UNIX stream (AF_UNIX) tests on Windows.
Patch written by Claudiu Popa.
This commit is contained in:
parent
d4d39c761c
commit
ec5a860e60
1 changed files with 12 additions and 10 deletions
|
@ -865,9 +865,6 @@ if threading:
|
||||||
super(TestTCPServer, self).server_bind()
|
super(TestTCPServer, self).server_bind()
|
||||||
self.port = self.socket.getsockname()[1]
|
self.port = self.socket.getsockname()[1]
|
||||||
|
|
||||||
class TestUnixStreamServer(TestTCPServer):
|
|
||||||
address_family = socket.AF_UNIX
|
|
||||||
|
|
||||||
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
||||||
"""
|
"""
|
||||||
A UDP server which is controllable using :class:`ControlMixin`.
|
A UDP server which is controllable using :class:`ControlMixin`.
|
||||||
|
@ -915,8 +912,12 @@ if threading:
|
||||||
super(TestUDPServer, self).server_close()
|
super(TestUDPServer, self).server_close()
|
||||||
self._closed = True
|
self._closed = True
|
||||||
|
|
||||||
class TestUnixDatagramServer(TestUDPServer):
|
if hasattr(socket, "AF_UNIX"):
|
||||||
address_family = socket.AF_UNIX
|
class TestUnixStreamServer(TestTCPServer):
|
||||||
|
address_family = socket.AF_UNIX
|
||||||
|
|
||||||
|
class TestUnixDatagramServer(TestUDPServer):
|
||||||
|
address_family = socket.AF_UNIX
|
||||||
|
|
||||||
# - end of server_helper section
|
# - end of server_helper section
|
||||||
|
|
||||||
|
@ -1457,12 +1458,13 @@ def _get_temp_domain_socket():
|
||||||
os.remove(fn)
|
os.remove(fn)
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
||||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class UnixSocketHandlerTest(SocketHandlerTest):
|
class UnixSocketHandlerTest(SocketHandlerTest):
|
||||||
|
|
||||||
"""Test for SocketHandler with unix sockets."""
|
"""Test for SocketHandler with unix sockets."""
|
||||||
|
|
||||||
if threading:
|
if threading and hasattr(socket, "AF_UNIX"):
|
||||||
server_class = TestUnixStreamServer
|
server_class = TestUnixStreamServer
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -1528,13 +1530,13 @@ class DatagramHandlerTest(BaseTest):
|
||||||
self.handled.wait()
|
self.handled.wait()
|
||||||
self.assertEqual(self.log_output, "spam\neggs\n")
|
self.assertEqual(self.log_output, "spam\neggs\n")
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
||||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class UnixDatagramHandlerTest(DatagramHandlerTest):
|
class UnixDatagramHandlerTest(DatagramHandlerTest):
|
||||||
|
|
||||||
"""Test for DatagramHandler using Unix sockets."""
|
"""Test for DatagramHandler using Unix sockets."""
|
||||||
|
|
||||||
if threading:
|
if threading and hasattr(socket, "AF_UNIX"):
|
||||||
server_class = TestUnixDatagramServer
|
server_class = TestUnixDatagramServer
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -1603,13 +1605,13 @@ class SysLogHandlerTest(BaseTest):
|
||||||
self.handled.wait()
|
self.handled.wait()
|
||||||
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
|
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
||||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class UnixSysLogHandlerTest(SysLogHandlerTest):
|
class UnixSysLogHandlerTest(SysLogHandlerTest):
|
||||||
|
|
||||||
"""Test for SysLogHandler with Unix sockets."""
|
"""Test for SysLogHandler with Unix sockets."""
|
||||||
|
|
||||||
if threading:
|
if threading and hasattr(socket, "AF_UNIX"):
|
||||||
server_class = TestUnixDatagramServer
|
server_class = TestUnixDatagramServer
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue