Hai Shi | bb0424b | 2020-08-04 00:47:42 +0800 | [diff] [blame^] | 1 | from test.support import import_helper |
| 2 | syslog = import_helper.import_module("syslog") #skip if not supported |
Kristján Valur Jónsson | 42a40c5 | 2009-04-01 11:28:47 +0000 | [diff] [blame] | 3 | import unittest |
Neal Norwitz | 8d3654d | 2007-08-25 00:21:36 +0000 | [diff] [blame] | 4 | |
| 5 | # XXX(nnorwitz): This test sucks. I don't know of a platform independent way |
| 6 | # to verify that the messages were really logged. |
| 7 | # The only purpose of this test is to verify the code doesn't crash or leak. |
| 8 | |
| 9 | class Test(unittest.TestCase): |
| 10 | |
| 11 | def test_openlog(self): |
| 12 | syslog.openlog('python') |
Alexander Belopolsky | e239d23 | 2010-12-08 23:31:48 +0000 | [diff] [blame] | 13 | # Issue #6697. |
| 14 | self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800') |
Neal Norwitz | 8d3654d | 2007-08-25 00:21:36 +0000 | [diff] [blame] | 15 | |
| 16 | def test_syslog(self): |
| 17 | syslog.openlog('python') |
| 18 | syslog.syslog('test message from python test_syslog') |
| 19 | syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog') |
| 20 | |
| 21 | def test_closelog(self): |
| 22 | syslog.openlog('python') |
| 23 | syslog.closelog() |
| 24 | |
| 25 | def test_setlogmask(self): |
| 26 | syslog.setlogmask(syslog.LOG_DEBUG) |
| 27 | |
| 28 | def test_log_mask(self): |
| 29 | syslog.LOG_MASK(syslog.LOG_INFO) |
| 30 | |
| 31 | def test_log_upto(self): |
| 32 | syslog.LOG_UPTO(syslog.LOG_INFO) |
| 33 | |
Christian Heimes | ac98a4e | 2013-12-05 13:56:56 +0100 | [diff] [blame] | 34 | def test_openlog_noargs(self): |
| 35 | syslog.openlog() |
| 36 | syslog.syslog('test message from python test_syslog') |
| 37 | |
Neal Norwitz | 8d3654d | 2007-08-25 00:21:36 +0000 | [diff] [blame] | 38 | if __name__ == "__main__": |
Zachary Ware | 38c707e | 2015-04-13 15:00:43 -0500 | [diff] [blame] | 39 | unittest.main() |