Skip to content

Commit ec5a860

Browse files
committed
Issue python#21636: Fix test_logging, skip UNIX stream (AF_UNIX) tests on Windows.
Patch written by Claudiu Popa.
1 parent d4d39c7 commit ec5a860

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

Lib/test/test_logging.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,6 @@ def server_bind(self):
865865
super(TestTCPServer, self).server_bind()
866866
self.port = self.socket.getsockname()[1]
867867

868-
class TestUnixStreamServer(TestTCPServer):
869-
address_family = socket.AF_UNIX
870-
871868
class TestUDPServer(ControlMixin, ThreadingUDPServer):
872869
"""
873870
A UDP server which is controllable using :class:`ControlMixin`.
@@ -915,8 +912,12 @@ def server_close(self):
915912
super(TestUDPServer, self).server_close()
916913
self._closed = True
917914

918-
class TestUnixDatagramServer(TestUDPServer):
919-
address_family = socket.AF_UNIX
915+
if hasattr(socket, "AF_UNIX"):
916+
class TestUnixStreamServer(TestTCPServer):
917+
address_family = socket.AF_UNIX
918+
919+
class TestUnixDatagramServer(TestUDPServer):
920+
address_family = socket.AF_UNIX
920921

921922
# - end of server_helper section
922923

@@ -1457,12 +1458,13 @@ def _get_temp_domain_socket():
14571458
os.remove(fn)
14581459
return fn
14591460

1461+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
14601462
@unittest.skipUnless(threading, 'Threading required for this test.')
14611463
class UnixSocketHandlerTest(SocketHandlerTest):
14621464

14631465
"""Test for SocketHandler with unix sockets."""
14641466

1465-
if threading:
1467+
if threading and hasattr(socket, "AF_UNIX"):
14661468
server_class = TestUnixStreamServer
14671469

14681470
def setUp(self):
@@ -1528,13 +1530,13 @@ def test_output(self):
15281530
self.handled.wait()
15291531
self.assertEqual(self.log_output, "spam\neggs\n")
15301532

1531-
1533+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
15321534
@unittest.skipUnless(threading, 'Threading required for this test.')
15331535
class UnixDatagramHandlerTest(DatagramHandlerTest):
15341536

15351537
"""Test for DatagramHandler using Unix sockets."""
15361538

1537-
if threading:
1539+
if threading and hasattr(socket, "AF_UNIX"):
15381540
server_class = TestUnixDatagramServer
15391541

15401542
def setUp(self):
@@ -1603,13 +1605,13 @@ def test_output(self):
16031605
self.handled.wait()
16041606
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
16051607

1606-
1608+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
16071609
@unittest.skipUnless(threading, 'Threading required for this test.')
16081610
class UnixSysLogHandlerTest(SysLogHandlerTest):
16091611

16101612
"""Test for SysLogHandler with Unix sockets."""
16111613

1612-
if threading:
1614+
if threading and hasattr(socket, "AF_UNIX"):
16131615
server_class = TestUnixDatagramServer
16141616

16151617
def setUp(self):

0 commit comments

Comments
 (0)