Skip to content

Commit

Permalink
Test readline.set_auto_history()
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanor committed May 31, 2021
1 parent a4bfd8d commit 007a8af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions testing/test_readline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 007a8af

Please sign in to comment.