[3.11] Add more syslog tests (GH-97953). (GH-98096)

(cherry picked from commit cae7d1d7a7)
This commit is contained in:
Serhiy Storchaka 2022-10-08 22:22:26 +03:00 committed by GitHub
parent bdc1087724
commit f6e50b82f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 7 deletions

View file

@ -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()