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

Method test_write_read_limited_history

Lib/test/test_readline.py:396–414  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

394
395
396 def test_write_read_limited_history(self):
397 previous_length = readline.get_history_length()
398 self.addCleanup(readline.set_history_length, previous_length)
399
400 readline.add_history("first line")
401 readline.add_history("second line")
402 readline.add_history("third line")
403
404 readline.set_history_length(2)
405 self.assertEqual(readline.get_history_length(), 2)
406 readline.write_history_file(TESTFN)
407 self.addCleanup(os.remove, TESTFN)
408
409 readline.read_history_file(TESTFN)
410 # Without clear_history() there's no good way to test if
411 # the correct entries are present (we're combining history limiting and
412 # possible deduplication with arbitrary previous content).
413 # So, we've only tested that the read did not fail.
414 # See TestHistoryManipulation for the full test.
415
416 @unittest.skipUnless(hasattr(readline, "get_pre_input_hook"),
417 "get_pre_input_hook not available")

Callers

nothing calls this directly

Calls 7

get_history_lengthMethod · 0.80
addCleanupMethod · 0.80
add_historyMethod · 0.80
set_history_lengthMethod · 0.80
write_history_fileMethod · 0.80
read_history_fileMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected