diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-06-07 16:52:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-07 16:52:17 -0700 |
commit | e4d13c745b7b983eb444e97f467b572a885d220c (patch) | |
tree | 97aa7c7151cc8f5c6923d0d965d650af75d7115e /tests/test_transcript.py | |
parent | dde5207c22d041b97981de47758317d15a3fc329 (diff) | |
parent | d0e71c85190b81bb269cc18bf9380a142e18d707 (diff) | |
download | cmd2-git-e4d13c745b7b983eb444e97f467b572a885d220c.tar.gz |
Merge branch 'master' into autocompleter
Diffstat (limited to 'tests/test_transcript.py')
-rw-r--r-- | tests/test_transcript.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_transcript.py b/tests/test_transcript.py index 302d80c8..3caf6a37 100644 --- a/tests/test_transcript.py +++ b/tests/test_transcript.py @@ -154,6 +154,32 @@ this is a \/multiline\/ command assert transcript == expected +def test_history_transcript_bad_filename(request, capsys): + app = CmdLineApp() + app.stdout = StdOut() + run_cmd(app, 'orate this is\na /multiline/\ncommand;\n') + run_cmd(app, 'speak /tmp/file.txt is not a regex') + + expected = r"""(Cmd) orate this is +> a /multiline/ +> command; +this is a \/multiline\/ command +(Cmd) speak /tmp/file.txt is not a regex +\/tmp\/file.txt is not a regex +""" + + # make a tmp file + history_fname = '~/fakedir/this_does_not_exist.txt' + + # tell the history command to create a transcript + run_cmd(app, 'history -t "{}"'.format(history_fname)) + + # read in the transcript created by the history command + with pytest.raises(FileNotFoundError): + with open(history_fname) as f: + transcript = f.read() + assert transcript == expected + @pytest.mark.parametrize('expected, transformed', [ # strings with zero or one slash or with escaped slashes means no regular # expression present, so the result should just be what re.escape returns. |