MCPcopy Create free account
hub / github.com/python/cpython / test_not_wiping_history_file

Method test_not_wiping_history_file

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

Source from the content-addressed store, hash-verified

2112 check(output, exit_code)
2113
2114 def test_not_wiping_history_file(self):
2115 # skip, if readline module is not available
2116 import_module('readline')
2117
2118 hfile = tempfile.NamedTemporaryFile(delete=False)
2119 self.addCleanup(unlink, hfile.name)
2120 env = os.environ.copy()
2121 env["PYTHON_HISTORY"] = hfile.name
2122 commands = "123\nspam\nexit()\n"
2123
2124 env.pop("PYTHON_BASIC_REPL", None)
2125 output, exit_code = self.run_repl(commands, env=env)
2126 self.assertEqual(exit_code, 0)
2127 self.assertIn("123", output)
2128 self.assertIn("spam", output)
2129 self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
2130
2131 hfile.file.truncate()
2132 hfile.close()
2133
2134 env["PYTHON_BASIC_REPL"] = "1"
2135 output, exit_code = self.run_repl(commands, env=env)
2136 self.assertEqual(exit_code, 0)
2137 self.assertIn("123", output)
2138 self.assertIn("spam", output)
2139 self.assertNotEqual(pathlib.Path(hfile.name).stat().st_size, 0)
2140
2141 @force_not_colorized
2142 def test_correct_filename_in_syntaxerrors(self):

Callers

nothing calls this directly

Calls 11

import_moduleFunction · 0.90
addCleanupMethod · 0.80
assertInMethod · 0.80
assertNotEqualMethod · 0.80
copyMethod · 0.45
popMethod · 0.45
run_replMethod · 0.45
assertEqualMethod · 0.45
statMethod · 0.45
truncateMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected