Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(128654)

Side by Side Diff: Lib/test/test_logging.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_keyword.py ('k') | Lib/test/test_mailcap.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2001-2014 by Vinay Sajip. All Rights Reserved. 1 # Copyright 2001-2014 by Vinay Sajip. All Rights Reserved.
2 # 2 #
3 # Permission to use, copy, modify, and distribute this software and its 3 # Permission to use, copy, modify, and distribute this software and its
4 # documentation for any purpose and without fee is hereby granted, 4 # documentation for any purpose and without fee is hereby granted,
5 # provided that the above copyright notice appear in all copies and that 5 # provided that the above copyright notice appear in all copies and that
6 # both that copyright notice and this permission notice appear in 6 # both that copyright notice and this permission notice appear in
7 # supporting documentation, and that the name of Vinay Sajip 7 # supporting documentation, and that the name of Vinay Sajip
8 # not be used in advertising or publicity pertaining to distribution 8 # not be used in advertising or publicity pertaining to distribution
9 # of the software without specific, written prior permission. 9 # of the software without specific, written prior permission.
10 # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 10 # VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 self.assertGreater(self.sock_hdlr.retryTime, now) 1445 self.assertGreater(self.sock_hdlr.retryTime, now)
1446 time.sleep(self.sock_hdlr.retryTime - now + 0.001) 1446 time.sleep(self.sock_hdlr.retryTime - now + 0.001)
1447 self.root_logger.error('Nor this') 1447 self.root_logger.error('Nor this')
1448 1448
1449 def _get_temp_domain_socket(): 1449 def _get_temp_domain_socket():
1450 fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.sock') 1450 fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.sock')
1451 os.close(fd) 1451 os.close(fd)
1452 # just need a name - file can't be present, or we'll get an 1452 # just need a name - file can't be present, or we'll get an
1453 # 'address already in use' error. 1453 # 'address already in use' error.
1454 os.remove(fn) 1454 os.remove(fn)
1455 # Check the size of the socket file name. If it exceeds 108
1456 # characters (UNIX_PATH_MAX), it can't be used as a UNIX socket.
1457 # In this case, fall back to a path constructed somewhere that
1458 # is known to be short.
1459 if len(fn) > 108:
1460 fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.sock', dir='/ tmp')
1461 os.close(fd)
1462 # just need a name - file can't be present, or we'll get an
1463 # 'address already in use' error.
1464 os.remove(fn)
1455 return fn 1465 return fn
1456 1466
1457 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required") 1467 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
1468 @unittest.skipIf(sys.platform == 'ios', "iOS doesn't fully support UNIX sockets. ")
1458 @unittest.skipUnless(threading, 'Threading required for this test.') 1469 @unittest.skipUnless(threading, 'Threading required for this test.')
1459 class UnixSocketHandlerTest(SocketHandlerTest): 1470 class UnixSocketHandlerTest(SocketHandlerTest):
1460 1471
1461 """Test for SocketHandler with unix sockets.""" 1472 """Test for SocketHandler with unix sockets."""
1462 1473
1463 if threading and hasattr(socket, "AF_UNIX"): 1474 if threading and hasattr(socket, "AF_UNIX"):
1464 server_class = TestUnixStreamServer 1475 server_class = TestUnixStreamServer
1465 1476
1466 def setUp(self): 1477 def setUp(self):
1467 # override the definition in the base class 1478 # override the definition in the base class
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 # The log message sent to the DatagramHandler is properly received. 1531 # The log message sent to the DatagramHandler is properly received.
1521 logger = logging.getLogger("udp") 1532 logger = logging.getLogger("udp")
1522 logger.error("spam") 1533 logger.error("spam")
1523 self.handled.wait() 1534 self.handled.wait()
1524 self.handled.clear() 1535 self.handled.clear()
1525 logger.error("eggs") 1536 logger.error("eggs")
1526 self.handled.wait() 1537 self.handled.wait()
1527 self.assertEqual(self.log_output, "spam\neggs\n") 1538 self.assertEqual(self.log_output, "spam\neggs\n")
1528 1539
1529 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required") 1540 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
1541 @unittest.skipIf(sys.platform == 'ios', "iOS doesn't fully support UNIX sockets. ")
1530 @unittest.skipUnless(threading, 'Threading required for this test.') 1542 @unittest.skipUnless(threading, 'Threading required for this test.')
1531 class UnixDatagramHandlerTest(DatagramHandlerTest): 1543 class UnixDatagramHandlerTest(DatagramHandlerTest):
1532 1544
1533 """Test for DatagramHandler using Unix sockets.""" 1545 """Test for DatagramHandler using Unix sockets."""
1534 1546
1535 if threading and hasattr(socket, "AF_UNIX"): 1547 if threading and hasattr(socket, "AF_UNIX"):
1536 server_class = TestUnixDatagramServer 1548 server_class = TestUnixDatagramServer
1537 1549
1538 def setUp(self): 1550 def setUp(self):
1539 # override the definition in the base class 1551 # override the definition in the base class
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 logger.error("sp\xe4m") 1607 logger.error("sp\xe4m")
1596 self.handled.wait() 1608 self.handled.wait()
1597 self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m') 1609 self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m')
1598 self.handled.clear() 1610 self.handled.clear()
1599 self.sl_hdlr.ident = "h\xe4m-" 1611 self.sl_hdlr.ident = "h\xe4m-"
1600 logger.error("sp\xe4m") 1612 logger.error("sp\xe4m")
1601 self.handled.wait() 1613 self.handled.wait()
1602 self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m') 1614 self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
1603 1615
1604 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required") 1616 @unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
1617 @unittest.skipIf(sys.platform == 'ios', "iOS doesn't fully support UNIX sockets. ")
1605 @unittest.skipUnless(threading, 'Threading required for this test.') 1618 @unittest.skipUnless(threading, 'Threading required for this test.')
1606 class UnixSysLogHandlerTest(SysLogHandlerTest): 1619 class UnixSysLogHandlerTest(SysLogHandlerTest):
1607 1620
1608 """Test for SysLogHandler with Unix sockets.""" 1621 """Test for SysLogHandler with Unix sockets."""
1609 1622
1610 if threading and hasattr(socket, "AF_UNIX"): 1623 if threading and hasattr(socket, "AF_UNIX"):
1611 server_class = TestUnixDatagramServer 1624 server_class = TestUnixDatagramServer
1612 1625
1613 def setUp(self): 1626 def setUp(self):
1614 # override the definition in the base class 1627 # override the definition in the base class
(...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest, BasicConfigTest, 4197 QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest, BasicConfigTest,
4185 LoggerAdapterTest, LoggerTest, SMTPHandlerTest, FileHandlerTest, 4198 LoggerAdapterTest, LoggerTest, SMTPHandlerTest, FileHandlerTest,
4186 RotatingFileHandlerTest, LastResortTest, LogRecordTest, 4199 RotatingFileHandlerTest, LastResortTest, LogRecordTest,
4187 ExceptionTest, SysLogHandlerTest, HTTPHandlerTest, 4200 ExceptionTest, SysLogHandlerTest, HTTPHandlerTest,
4188 NTEventLogHandlerTest, TimedRotatingFileHandlerTest, 4201 NTEventLogHandlerTest, TimedRotatingFileHandlerTest,
4189 UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest, 4202 UnixSocketHandlerTest, UnixDatagramHandlerTest, UnixSysLogHandlerTest,
4190 MiscTestCase) 4203 MiscTestCase)
4191 4204
4192 if __name__ == "__main__": 4205 if __name__ == "__main__":
4193 test_main() 4206 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_keyword.py ('k') | Lib/test/test_mailcap.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+