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