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

Method test_python_basic_repl

Lib/test/test_pyrepl/test_pyrepl.py:2037–2065  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2035
2036 @force_not_colorized
2037 def test_python_basic_repl(self):
2038 env = os.environ.copy()
2039 pyrepl_commands = "clear\nexit()\n"
2040 env.pop("PYTHON_BASIC_REPL", None)
2041 output, exit_code = self.run_repl(pyrepl_commands, env=env, skip=True)
2042 self.assertEqual(exit_code, 0)
2043 self.assertNotIn("Exception", output)
2044 self.assertNotIn("NameError", output)
2045 self.assertNotIn("Traceback", output)
2046
2047 basic_commands = "help\nexit()\n"
2048 env["PYTHON_BASIC_REPL"] = "1"
2049 output, exit_code = self.run_repl(basic_commands, env=env)
2050 self.assertEqual(exit_code, 0)
2051 self.assertIn("Type help() for interactive help", output)
2052 self.assertNotIn("Exception", output)
2053 self.assertNotIn("Traceback", output)
2054
2055 # The site module must not load _pyrepl if PYTHON_BASIC_REPL is set
2056 commands = ("import sys\n"
2057 "print('_pyrepl' in sys.modules)\n"
2058 "exit()\n")
2059 env["PYTHON_BASIC_REPL"] = "1"
2060 output, exit_code = self.run_repl(commands, env=env)
2061 self.assertEqual(exit_code, 0)
2062 self.assertIn("False", output)
2063 self.assertNotIn("True", output)
2064 self.assertNotIn("Exception", output)
2065 self.assertNotIn("Traceback", output)
2066
2067 @force_not_colorized
2068 def test_no_pyrepl_source_in_exc(self):

Callers

nothing calls this directly

Calls 6

assertNotInMethod · 0.80
assertInMethod · 0.80
copyMethod · 0.45
popMethod · 0.45
run_replMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected