1from test.support import import_helper
2syslog = import_helper.import_module("syslog") #skip if not supported
3import unittest
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
9class Test(unittest.TestCase):
10
11    def test_openlog(self):
12        syslog.openlog('python')
13        # Issue #6697.
14        self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
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
34    def test_openlog_noargs(self):
35        syslog.openlog()
36        syslog.syslog('test message from python test_syslog')
37
38if __name__ == "__main__":
39    unittest.main()
40