blob: fe09bd39f8b7fd95a401cbe0b5d3d8e0e2125db5 [file] [log] [blame]
Hai Shibb0424b2020-08-04 00:47:42 +08001from test.support import import_helper
2syslog = import_helper.import_module("syslog") #skip if not supported
Kristján Valur Jónsson42a40c52009-04-01 11:28:47 +00003import unittest
Neal Norwitz8d3654d2007-08-25 00:21:36 +00004
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
9class Test(unittest.TestCase):
10
11 def test_openlog(self):
12 syslog.openlog('python')
Alexander Belopolskye239d232010-12-08 23:31:48 +000013 # Issue #6697.
14 self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
Neal Norwitz8d3654d2007-08-25 00:21:36 +000015
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 Heimesac98a4e2013-12-05 13:56:56 +010034 def test_openlog_noargs(self):
35 syslog.openlog()
36 syslog.syslog('test message from python test_syslog')
37
Neal Norwitz8d3654d2007-08-25 00:21:36 +000038if __name__ == "__main__":
Zachary Ware38c707e2015-04-13 15:00:43 -050039 unittest.main()