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

Method test_exit

Lib/test/test__interpreters.py:927–951  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

925 self._assert_run_failed(exctype, msg, script)
926
927 def test_exit(self):
928 with self.subTest('sys.exit(0)'):
929 # XXX Should an unhandled SystemExit(0) be handled as not-an-error?
930 self.assert_run_failed(SystemExit, """
931 sys.exit(0)
932 """)
933
934 with self.subTest('sys.exit()'):
935 self.assert_run_failed(SystemExit, """
936 import sys
937 sys.exit()
938 """)
939
940 with self.subTest('sys.exit(42)'):
941 self.assert_run_failed_msg(SystemExit, '42', """
942 import sys
943 sys.exit(42)
944 """)
945
946 with self.subTest('SystemExit'):
947 self.assert_run_failed_msg(SystemExit, '42', """
948 raise SystemExit(42)
949 """)
950
951 # XXX Also check os._exit() (via a subprocess)?
952
953 def test_plain_exception(self):
954 self.assert_run_failed_msg(Exception, 'spam', """

Callers

nothing calls this directly

Calls 3

assert_run_failedMethod · 0.95
assert_run_failed_msgMethod · 0.95
subTestMethod · 0.45

Tested by

no test coverage detected