Skip to content

Commit 007a8af

Browse files
committed
Test readline.set_auto_history()
1 parent a4bfd8d commit 007a8af

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

testing/test_readline.py

+12
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ def replace(cls, *args):
103103
readline_wrapper.write_history_file(str(histfile))
104104

105105
assert open(str(histfile), "r").readlines() == ["foo\n", "bar\n"]
106+
107+
108+
@pytest.mark.parametrize('auto_history,expected', [(True, 1), (False, 0)])
109+
def test_set_auto_history(auto_history, expected):
110+
master, slave = pty.openpty()
111+
readline_wrapper = _ReadlineWrapper(slave, slave)
112+
readline_wrapper.set_auto_history(auto_history)
113+
114+
os.write(master, b'input\n')
115+
readline_wrapper.get_reader().readline()
116+
117+
assert readline_wrapper.get_current_history_length() == expected

0 commit comments

Comments
 (0)