File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -349,6 +349,26 @@ def test_history_size(self):
349
349
self .assertEqual (len (lines ), history_size )
350
350
self .assertEqual (lines [- 1 ].strip (), b"last input" )
351
351
352
+ def test_write_read_limited_history (self ):
353
+ previous_length = readline .get_history_length ()
354
+ self .addCleanup (readline .set_history_length , previous_length )
355
+
356
+ readline .add_history ("first line" )
357
+ readline .add_history ("second line" )
358
+ readline .add_history ("third line" )
359
+
360
+ readline .set_history_length (2 )
361
+ self .assertEqual (readline .get_history_length (), 2 )
362
+ readline .write_history_file (TESTFN )
363
+ self .addCleanup (os .remove , TESTFN )
364
+
365
+ readline .read_history_file (TESTFN )
366
+ # Without clear_history() there's no good way to test if
367
+ # the correct entries are present (we're combining history limiting and
368
+ # possible deduplication with arbitrary previous content).
369
+ # So, we've only tested that the read did not fail.
370
+ # See TestHistoryManipulation for the full test.
371
+
352
372
353
373
if __name__ == "__main__" :
354
374
unittest .main ()
You can’t perform that action at this time.
0 commit comments