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

Method test_readline_history_file

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

Source from the content-addressed store, hash-verified

2197 self.assertIn("bluch", output)
2198
2199 def test_readline_history_file(self):
2200 # skip, if readline module is not available
2201 readline = import_module('readline')
2202 if readline.backend != "editline":
2203 self.skipTest("GNU readline is not affected by this issue")
2204
2205 with tempfile.NamedTemporaryFile() as hfile:
2206 env = os.environ.copy()
2207 env["PYTHON_HISTORY"] = hfile.name
2208
2209 env["PYTHON_BASIC_REPL"] = "1"
2210 output, exit_code = self.run_repl("spam \nexit()\n", env=env)
2211 self.assertEqual(exit_code, 0)
2212 self.assertIn("spam ", output)
2213 self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
2214 self.assertIn("spam\\040", pathlib.Path(hfile.name).read_text())
2215
2216 env.pop("PYTHON_BASIC_REPL", None)
2217 output, exit_code = self.run_repl("exit\n", env=env)
2218 self.assertEqual(exit_code, 0)
2219 self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text())
2220
2221 def test_history_survive_crash(self):
2222 env = os.environ.copy()

Callers

nothing calls this directly

Calls 11

import_moduleFunction · 0.90
skipTestMethod · 0.80
assertInMethod · 0.80
assertNotEqualMethod · 0.80
assertNotInMethod · 0.80
copyMethod · 0.45
run_replMethod · 0.45
assertEqualMethod · 0.45
statMethod · 0.45
read_textMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected