MCPcopy Index your code
hub / github.com/RustPython/RustPython / Test

Class Test

Lib/test/test_syslog.py:13–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11# The only purpose of this test is to verify the code doesn't crash or leak.
12
13class Test(unittest.TestCase):
14
15 def tearDown(self):
16 syslog.closelog()
17
18 # TODO: RUSTPYTHON
19 @unittest.expectedFailure
20 def test_openlog(self):
21 syslog.openlog('python')
22 # Issue #6697.
23 self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
24
25 def test_syslog(self):
26 syslog.openlog('python')
27 syslog.syslog('test message from python test_syslog')
28 syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
29
30 def test_syslog_implicit_open(self):
31 syslog.closelog() # Make sure log is closed
32 syslog.syslog('test message from python test_syslog')
33 syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
34
35 def test_closelog(self):
36 syslog.openlog('python')
37 syslog.closelog()
38 syslog.closelog() # idempotent operation
39
40 def test_setlogmask(self):
41 mask = syslog.LOG_UPTO(syslog.LOG_WARNING)
42 oldmask = syslog.setlogmask(mask)
43 self.assertEqual(syslog.setlogmask(0), mask)
44 self.assertEqual(syslog.setlogmask(oldmask), mask)
45
46 # TODO: RUSTPYTHON; AssertionError: 12 is not false
47 @unittest.expectedFailure
48 def test_log_mask(self):
49 mask = syslog.LOG_UPTO(syslog.LOG_WARNING)
50 self.assertTrue(mask & syslog.LOG_MASK(syslog.LOG_WARNING))
51 self.assertTrue(mask & syslog.LOG_MASK(syslog.LOG_ERR))
52 self.assertFalse(mask & syslog.LOG_MASK(syslog.LOG_INFO))
53
54 def test_openlog_noargs(self):
55 syslog.openlog()
56 syslog.syslog('test message from python test_syslog')
57
58 @threading_helper.requires_working_threading()
59 def test_syslog_threaded(self):
60 start = threading.Event()
61 stop = False
62 def opener():
63 start.wait(10)
64 i = 1
65 while not stop:
66 syslog.openlog(f'python-test-{i}') # new string object
67 i += 1
68 def logger():
69 start.wait(10)
70 while not stop:

Callers 2

__init__Method · 0.70
test_type_genericMethod · 0.70

Calls

no outgoing calls

Tested by 2

__init__Method · 0.56
test_type_genericMethod · 0.56