mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
[3.11] Add more syslog tests (GH-97953). (GH-98096)
(cherry picked from commit cae7d1d7a7
)
This commit is contained in:
parent
bdc1087724
commit
f6e50b82f6
4 changed files with 97 additions and 7 deletions
|
@ -16,6 +16,7 @@ AUDIT_TESTS_PY = support.findfile("audit-tests.py")
|
|||
|
||||
|
||||
class AuditTest(unittest.TestCase):
|
||||
maxDiff = None
|
||||
|
||||
@support.requires_subprocess()
|
||||
def do_test(self, *args):
|
||||
|
@ -185,5 +186,29 @@ class AuditTest(unittest.TestCase):
|
|||
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_syslog(self):
|
||||
syslog = import_helper.import_module("syslog")
|
||||
|
||||
returncode, events, stderr = self.run_python("test_syslog")
|
||||
if returncode:
|
||||
self.fail(stderr)
|
||||
|
||||
if support.verbose:
|
||||
print('Events:', *events, sep='\n ')
|
||||
|
||||
self.assertSequenceEqual(
|
||||
events,
|
||||
[('syslog.openlog', ' ', f'python 0 {syslog.LOG_USER}'),
|
||||
('syslog.syslog', ' ', f'{syslog.LOG_INFO} test'),
|
||||
('syslog.setlogmask', ' ', f'{syslog.LOG_DEBUG}'),
|
||||
('syslog.closelog', '', ''),
|
||||
('syslog.syslog', ' ', f'{syslog.LOG_INFO} test2'),
|
||||
('syslog.openlog', ' ', f'audit-tests.py 0 {syslog.LOG_USER}'),
|
||||
('syslog.openlog', ' ', f'audit-tests.py {syslog.LOG_NDELAY} {syslog.LOG_LOCAL0}'),
|
||||
('syslog.openlog', ' ', f'None 0 {syslog.LOG_USER}'),
|
||||
('syslog.closelog', '', '')]
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue