From 007a8afb1e7dc2a2e57ff7857035c742c4158e4c Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Mon, 31 May 2021 12:40:39 -0400 Subject: [PATCH] Test readline.set_auto_history() --- testing/test_readline.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/testing/test_readline.py b/testing/test_readline.py index a9a2a2c..e67c019 100644 --- a/testing/test_readline.py +++ b/testing/test_readline.py @@ -103,3 +103,15 @@ def replace(cls, *args): readline_wrapper.write_history_file(str(histfile)) assert open(str(histfile), "r").readlines() == ["foo\n", "bar\n"] + + +@pytest.mark.parametrize('auto_history,expected', [(True, 1), (False, 0)]) +def test_set_auto_history(auto_history, expected): + master, slave = pty.openpty() + readline_wrapper = _ReadlineWrapper(slave, slave) + readline_wrapper.set_auto_history(auto_history) + + os.write(master, b'input\n') + readline_wrapper.get_reader().readline() + + assert readline_wrapper.get_current_history_length() == expected