[Python-checkins] cpython (3.4): Issue #21636: Fix test_logging, skip UNIX stream (AF_UNIX) tests on Windows.

victor.stinner python-checkins at python.org
Mon Jun 2 14:43:35 CEST 2014


http://hg.python.org/cpython/rev/d7a491c6cbdb
changeset: 90966:d7a491c6cbdb
branch: 3.4
parent: 90964:1318324aa93a
user: Victor Stinner <victor.stinner at gmail.com>
date: Mon Jun 02 14:41:51 2014 +0200
summary:
 Issue #21636: Fix test_logging, skip UNIX stream (AF_UNIX) tests on Windows.
Patch written by Claudiu Popa.
files:
 Lib/test/test_logging.py | 22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -865,9 +865,6 @@
 super(TestTCPServer, self).server_bind()
 self.port = self.socket.getsockname()[1]
 
- class TestUnixStreamServer(TestTCPServer):
- address_family = socket.AF_UNIX
-
 class TestUDPServer(ControlMixin, ThreadingUDPServer):
 """
 A UDP server which is controllable using :class:`ControlMixin`.
@@ -915,8 +912,12 @@
 super(TestUDPServer, self).server_close()
 self._closed = True
 
- class TestUnixDatagramServer(TestUDPServer):
- address_family = socket.AF_UNIX
+ if hasattr(socket, "AF_UNIX"):
+ class TestUnixStreamServer(TestTCPServer):
+ address_family = socket.AF_UNIX
+
+ class TestUnixDatagramServer(TestUDPServer):
+ address_family = socket.AF_UNIX
 
 # - end of server_helper section
 
@@ -1457,12 +1458,13 @@
 os.remove(fn)
 return fn
 
+ at unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class UnixSocketHandlerTest(SocketHandlerTest):
 
 """Test for SocketHandler with unix sockets."""
 
- if threading:
+ if threading and hasattr(socket, "AF_UNIX"):
 server_class = TestUnixStreamServer
 
 def setUp(self):
@@ -1528,13 +1530,13 @@
 self.handled.wait()
 self.assertEqual(self.log_output, "spam\neggs\n")
 
-
+ at unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class UnixDatagramHandlerTest(DatagramHandlerTest):
 
 """Test for DatagramHandler using Unix sockets."""
 
- if threading:
+ if threading and hasattr(socket, "AF_UNIX"):
 server_class = TestUnixDatagramServer
 
 def setUp(self):
@@ -1603,13 +1605,13 @@
 self.handled.wait()
 self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
 
-
+ at unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class UnixSysLogHandlerTest(SysLogHandlerTest):
 
 """Test for SysLogHandler with Unix sockets."""
 
- if threading:
+ if threading and hasattr(socket, "AF_UNIX"):
 server_class = TestUnixDatagramServer
 
 def setUp(self):
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /