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

Method test_remote_exec_raises_audit_event

Lib/test/test_sys.py:2134–2149  ·  view source on GitHub ↗

Test remote exec raises an audit event

(self)

Source from the content-addressed store, hash-verified

2132 self.assertEqual(mock_stdout.getvalue(), "Done\n")
2133
2134 def test_remote_exec_raises_audit_event(self):
2135 """Test remote exec raises an audit event"""
2136 prologue = '''\
2137import sys
2138def audit_hook(event, arg):
2139 print(f"Audit event: {event}, arg: {arg}".encode("ascii", errors="replace"))
2140sys.addaudithook(audit_hook)
2141'''
2142 script = '''
2143print("Remote script executed successfully!")
2144'''
2145 returncode, stdout, stderr = self._run_remote_exec_test(script, prologue=prologue)
2146 self.assertEqual(returncode, 0)
2147 self.assertIn(b"Remote script executed successfully!", stdout)
2148 self.assertIn(b"Audit event: cpython.remote_debugger_script, arg: ", stdout)
2149 self.assertEqual(stderr, b"")
2150
2151 def test_remote_exec_with_exception(self):
2152 """Test remote exec with an exception raised in the target process

Callers

nothing calls this directly

Calls 3

_run_remote_exec_testMethod · 0.95
assertInMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected