MCPcopy Index your code
hub / github.com/python/cpython / test_subinterpreter_syslog

Method test_subinterpreter_syslog

Lib/test/test_syslog.py:82–108  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

80 sys.setswitchinterval(orig_si)
81
82 def test_subinterpreter_syslog(self):
83 # syslog.syslog() is not allowed in subinterpreters, but only if
84 # syslog.openlog() hasn't been called in the main interpreter yet.
85 with self.subTest('before openlog()'):
86 code = dedent('''
87 import syslog
88 caught_error = False
89 try:
90 syslog.syslog('foo')
91 except RuntimeError:
92 caught_error = True
93 assert(caught_error)
94 ''')
95 res = support.run_in_subinterp(code)
96 self.assertEqual(res, 0)
97
98 syslog.openlog()
99 try:
100 with self.subTest('after openlog()'):
101 code = dedent('''
102 import syslog
103 syslog.syslog('foo')
104 ''')
105 res = support.run_in_subinterp(code)
106 self.assertEqual(res, 0)
107 finally:
108 syslog.closelog()
109
110 def test_subinterpreter_openlog(self):
111 try:

Callers

nothing calls this directly

Calls 3

dedentFunction · 0.90
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected