Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-95011: Migrate syslog module to Argument Clinic #95012

Merged
merged 22 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Lib/test/audit-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,20 @@ def hook(event, args):
sys._getframe()


def test_syslog():
noamcohen97 marked this conversation as resolved.
Show resolved Hide resolved
import syslog

def hook(event, args):
if event.startswith("syslog."):
print(event, *args)

sys.addaudithook(hook)
syslog.openlog('python')
syslog.syslog('test')
syslog.setlogmask(syslog.LOG_DEBUG)
syslog.closelog()


if __name__ == "__main__":
from test.support import suppress_msvcrt_asserts

Expand Down
21 changes: 21 additions & 0 deletions Lib/test/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,26 @@ def test_sys_getframe(self):

self.assertEqual(actual, expected)

def test_syslog(self):
noamcohen97 marked this conversation as resolved.
Show resolved Hide resolved
try:
import syslog
except ImportError:
return
noamcohen97 marked this conversation as resolved.
Show resolved Hide resolved

returncode, events, stderr = self.run_python("test_syslog")
if returncode:
self.fail(stderr)

if support.verbose:
print(*events, sep='\n')

self.assertSequenceEqual(
[('syslog.openlog', ' ', f'python 0 {syslog.LOG_USER}'),
('syslog.syslog', ' ', f'{syslog.LOG_INFO} test'),
('syslog.setlogmask', ' ', f'{syslog.LOG_DEBUG}'),
('syslog.closelog', '', '')],
events
)

if __name__ == "__main__":
unittest.main()
5 changes: 5 additions & 0 deletions Lib/test/test_syslog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ def test_syslog(self):
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')

def test_syslog_implicit_open(self):
syslog.closelog() # Make sure log is closed
syslog.syslog('test message from python test_syslog')
syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')

def test_closelog(self):
syslog.openlog('python')
syslog.closelog()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Migrated :mod:`syslog` to Argument Clinic. Patch by Noam Cohen.
228 changes: 228 additions & 0 deletions Modules/clinic/syslogmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading