Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ff3737

Browse files
committed
(Merge 3.4) Issue #21636: Fix test_logging, skip UNIX stream (AF_UNIX) tests on
Windows. Patch written by Claudiu Popa.
2 parents f849f46 + ec5a860 commit 8ff3737

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
@@ -860,9 +860,6 @@ def server_bind(self):
860860
super(TestTCPServer, self).server_bind()
861861
self.port = self.socket.getsockname()[1]
862862

863-
class TestUnixStreamServer(TestTCPServer):
864-
address_family = socket.AF_UNIX
865-
866863
class TestUDPServer(ControlMixin, ThreadingUDPServer):
867864
"""
868865
A UDP server which is controllable using :class:`ControlMixin`.
@@ -910,8 +907,12 @@ def server_close(self):
910907
super(TestUDPServer, self).server_close()
911908
self._closed = True
912909

913-
class TestUnixDatagramServer(TestUDPServer):
914-
address_family = socket.AF_UNIX
910+
if hasattr(socket, "AF_UNIX"):
911+
class TestUnixStreamServer(TestTCPServer):
912+
address_family = socket.AF_UNIX
913+
914+
class TestUnixDatagramServer(TestUDPServer):
915+
address_family = socket.AF_UNIX
915916

916917
# - end of server_helper section
917918

@@ -1452,12 +1453,13 @@ def _get_temp_domain_socket():
14521453
os.remove(fn)
14531454
return fn
14541455

1456+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
14551457
@unittest.skipUnless(threading, 'Threading required for this test.')
14561458
class UnixSocketHandlerTest(SocketHandlerTest):
14571459

14581460
"""Test for SocketHandler with unix sockets."""
14591461

1460-
if threading:
1462+
if threading and hasattr(socket, "AF_UNIX"):
14611463
server_class = TestUnixStreamServer
14621464

14631465
def setUp(self):
@@ -1523,13 +1525,13 @@ def test_output(self):
15231525
self.handled.wait()
15241526
self.assertEqual(self.log_output, "spam\neggs\n")
15251527

1526-
1528+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
15271529
@unittest.skipUnless(threading, 'Threading required for this test.')
15281530
class UnixDatagramHandlerTest(DatagramHandlerTest):
15291531

15301532
"""Test for DatagramHandler using Unix sockets."""
15311533

1532-
if threading:
1534+
if threading and hasattr(socket, "AF_UNIX"):
15331535
server_class = TestUnixDatagramServer
15341536

15351537
def setUp(self):
@@ -1598,13 +1600,13 @@ def test_output(self):
15981600
self.handled.wait()
15991601
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
16001602

1601-
1603+
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
16021604
@unittest.skipUnless(threading, 'Threading required for this test.')
16031605
class UnixSysLogHandlerTest(SysLogHandlerTest):
16041606

16051607
"""Test for SysLogHandler with Unix sockets."""
16061608

1607-
if threading:
1609+
if threading and hasattr(socket, "AF_UNIX"):
16081610
server_class = TestUnixDatagramServer
16091611

16101612
def setUp(self):

0 commit comments

Comments
 (0)