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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 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_locale.py ('k') | Lib/test/test_mailbox.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2001-2011 by Vinay Sajip. All Rights Reserved. 3 # Copyright 2001-2011 by Vinay Sajip. All Rights Reserved.
4 # 4 #
5 # Permission to use, copy, modify, and distribute this software and its 5 # Permission to use, copy, modify, and distribute this software and its
6 # documentation for any purpose and without fee is hereby granted, 6 # documentation for any purpose and without fee is hereby granted,
7 # provided that the above copyright notice appear in all copies and that 7 # provided that the above copyright notice appear in all copies and that
8 # both that copyright notice and this permission notice appear in 8 # both that copyright notice and this permission notice appear in
9 # supporting documentation, and that the name of Vinay Sajip 9 # supporting documentation, and that the name of Vinay Sajip
10 # not be used in advertising or publicity pertaining to distribution 10 # not be used in advertising or publicity pertaining to distribution
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 # The log message sent to the SysLogHandler is properly received. 1475 # The log message sent to the SysLogHandler is properly received.
1476 logger = logging.getLogger("slh") 1476 logger = logging.getLogger("slh")
1477 logger.error("sp\xe4m") 1477 logger.error("sp\xe4m")
1478 self.handled.wait() 1478 self.handled.wait()
1479 self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfsp\xc3\xa4m\x00') 1479 self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfsp\xc3\xa4m\x00')
1480 self.handled.clear() 1480 self.handled.clear()
1481 self.sl_hdlr.append_nul = False 1481 self.sl_hdlr.append_nul = False
1482 logger.error("sp\xe4m") 1482 logger.error("sp\xe4m")
1483 self.handled.wait() 1483 self.handled.wait()
1484 self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfsp\xc3\xa4m') 1484 self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfsp\xc3\xa4m')
1485 self.handled.clear()
1486 self.sl_hdlr.ident = "h\xe4m-"
1487 logger.error("sp\xe4m")
1488 self.handled.wait()
1489 self.assertEqual(self.log_output, b'<11>\xef\xbb\xbfh\xc3\xa4m-sp\xc3\xa 4m')
1490 1485
1491 1486
1492 @unittest.skipUnless(threading, 'Threading required for this test.') 1487 @unittest.skipUnless(threading, 'Threading required for this test.')
1493 class HTTPHandlerTest(BaseTest): 1488 class HTTPHandlerTest(BaseTest):
1494 """Test for HTTPHandler.""" 1489 """Test for HTTPHandler."""
1495 1490
1496 PEMFILE = """-----BEGIN RSA PRIVATE KEY----- 1491 PEMFILE = """-----BEGIN RSA PRIVATE KEY-----
1497 MIICXQIBAAKBgQDGT4xS5r91rbLJQK2nUDenBhBG6qFk+bVOjuAGC/LSHlAoBnvG 1492 MIICXQIBAAKBgQDGT4xS5r91rbLJQK2nUDenBhBG6qFk+bVOjuAGC/LSHlAoBnvG
1498 zQG3agOG+e7c5z2XT8m2ktORLqG3E4mYmbxgyhDrzP6ei2Anc+pszmnxPoK3Puh5 1493 zQG3agOG+e7c5z2XT8m2ktORLqG3E4mYmbxgyhDrzP6ei2Anc+pszmnxPoK3Puh5
1499 aXV+XKt0bU0C1m2+ACmGGJ0t3P408art82nOxBw8ZHgIg9Dtp6xIUCyOqwIDAQAB 1494 aXV+XKt0bU0C1m2+ACmGGJ0t3P408art82nOxBw8ZHgIg9Dtp6xIUCyOqwIDAQAB
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 class LastResortTest(BaseTest): 2911 class LastResortTest(BaseTest):
2917 def test_last_resort(self): 2912 def test_last_resort(self):
2918 # Test the last resort handler 2913 # Test the last resort handler
2919 root = self.root_logger 2914 root = self.root_logger
2920 root.removeHandler(self.root_hdlr) 2915 root.removeHandler(self.root_hdlr)
2921 old_stderr = sys.stderr 2916 old_stderr = sys.stderr
2922 old_lastresort = logging.lastResort 2917 old_lastresort = logging.lastResort
2923 old_raise_exceptions = logging.raiseExceptions 2918 old_raise_exceptions = logging.raiseExceptions
2924 try: 2919 try:
2925 sys.stderr = sio = io.StringIO() 2920 sys.stderr = sio = io.StringIO()
2926 root.debug('This should not appear')
2927 self.assertEqual(sio.getvalue(), '')
2928 root.warning('This is your final chance!') 2921 root.warning('This is your final chance!')
2929 self.assertEqual(sio.getvalue(), 'This is your final chance!\n') 2922 self.assertEqual(sio.getvalue(), 'This is your final chance!\n')
2930 #No handlers and no last resort, so 'No handlers' message 2923 #No handlers and no last resort, so 'No handlers' message
2931 logging.lastResort = None 2924 logging.lastResort = None
2932 sys.stderr = sio = io.StringIO() 2925 sys.stderr = sio = io.StringIO()
2933 root.warning('This is your final chance!') 2926 root.warning('This is your final chance!')
2934 self.assertEqual(sio.getvalue(), 'No handlers could be found for log ger "root"\n') 2927 self.assertEqual(sio.getvalue(), 'No handlers could be found for log ger "root"\n')
2935 # 'No handlers' message only printed once 2928 # 'No handlers' message only printed once
2936 sys.stderr = sio = io.StringIO() 2929 sys.stderr = sio = io.StringIO()
2937 root.warning('This is your final chance!') 2930 root.warning('This is your final chance!')
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest, 3711 QueueHandlerTest, ShutdownTest, ModuleLevelMiscTest,
3719 BasicConfigTest, LoggerAdapterTest, LoggerTest, 3712 BasicConfigTest, LoggerAdapterTest, LoggerTest,
3720 SMTPHandlerTest, FileHandlerTest, RotatingFileHandlerTest, 3713 SMTPHandlerTest, FileHandlerTest, RotatingFileHandlerTest,
3721 LastResortTest, LogRecordTest, ExceptionTest, 3714 LastResortTest, LogRecordTest, ExceptionTest,
3722 SysLogHandlerTest, HTTPHandlerTest, NTEventLogHandlerTest, 3715 SysLogHandlerTest, HTTPHandlerTest, NTEventLogHandlerTest,
3723 TimedRotatingFileHandlerTest 3716 TimedRotatingFileHandlerTest
3724 ) 3717 )
3725 3718
3726 if __name__ == "__main__": 3719 if __name__ == "__main__":
3727 test_main() 3720 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_locale.py ('k') | Lib/test/test_mailbox.py » ('j') | no next file with comments »

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