Update test_sys{log,_settrace}.py to 3.14.5 (#8030)

* Update `test_syslog.py` to 3.14.5

* Update `test_sys_settrace.py` to 3.14.5
This commit is contained in:
Shahar Naveh authored and GitHub committed 2026-06-03 22:51:41 +09:00
1 parent 5f789c6146
commit da99e72771
2 files changed
+1357 -141

No files matched your search

+1292 -139
View File
File diff suppressed because it is too large. Load diff
+65 -2
View File
@@ -5,6 +5,7 @@ import sys
import threading
import time
import unittest
from textwrap import dedent
# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
# to verify that the messages were really logged.
@@ -15,8 +16,7 @@ class Test(unittest.TestCase):
def tearDown(self):
syslog.closelog()
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_openlog(self):
syslog.openlog('python')
# Issue #6697.
@@ -80,6 +80,69 @@ class Test(unittest.TestCase):
finally:
sys.setswitchinterval(orig_si)
def test_subinterpreter_syslog(self):
# syslog.syslog() is not allowed in subinterpreters, but only if
# syslog.openlog() hasn't been called in the main interpreter yet.
with self.subTest('before openlog()'):
code = dedent('''
import syslog
caught_error = False
try:
syslog.syslog('foo')
except RuntimeError:
caught_error = True
assert(caught_error)
''')
res = support.run_in_subinterp(code)
self.assertEqual(res, 0)
syslog.openlog()
try:
with self.subTest('after openlog()'):
code = dedent('''
import syslog
syslog.syslog('foo')
''')
res = support.run_in_subinterp(code)
self.assertEqual(res, 0)
finally:
syslog.closelog()
def test_subinterpreter_openlog(self):
try:
code = dedent('''
import syslog
caught_error = False
try:
syslog.openlog()
except RuntimeError:
caught_error = True
assert(caught_error)
''')
res = support.run_in_subinterp(code)
self.assertEqual(res, 0)
finally:
syslog.closelog()
def test_subinterpreter_closelog(self):
syslog.openlog('python')
try:
code = dedent('''
import syslog
caught_error = False
try:
syslog.closelog()
except RuntimeError:
caught_error = True
assert(caught_error)
''')
res = support.run_in_subinterp(code)
self.assertEqual(res, 0)
finally:
syslog.closelog()
if __name__ == "__main__":
unittest.main()