diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-29 19:11:38 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-07-29 19:11:38 -0400 |
| commit | ede283decec7138b315b0c088a27c8f15c488335 (patch) | |
| tree | 3cb96b3cf74809c072bcf063e8484de82a4681b5 /tests | |
| parent | f419192b71f816952b4f160c6b97986a5b8c9fd9 (diff) | |
| download | cmd2-git-ede283decec7138b315b0c088a27c8f15c488335.tar.gz | |
Creating directory of persistent history file if it does not exist
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_history.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/test_history.py b/tests/test_history.py index 2da34cfd..2e6f13b9 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -638,6 +638,15 @@ def test_history_file_is_directory(capsys): _, err = capsys.readouterr() assert 'is a directory' in err +def test_history_cannot_create_directory(mocker, capsys): + mock_open = mocker.patch('os.makedirs') + mock_open.side_effect = OSError + + hist_file_path = os.path.join('fake_dir', 'file') + cmd2.Cmd(persistent_history_file=hist_file_path) + _, err = capsys.readouterr() + assert 'Error creating persistent history file directory' in err + def test_history_file_permission_error(mocker, capsys): mock_open = mocker.patch('builtins.open') mock_open.side_effect = PermissionError @@ -645,7 +654,7 @@ def test_history_file_permission_error(mocker, capsys): cmd2.Cmd(persistent_history_file='/tmp/doesntmatter') out, err = capsys.readouterr() assert not out - assert 'can not read' in err + assert 'Can not read' in err def test_history_file_conversion_no_truncate_on_init(hist_file, capsys): # make sure we don't truncate the plain text history file on init @@ -720,4 +729,4 @@ def test_persist_history_permission_error(hist_file, mocker, capsys): app._persist_history() out, err = capsys.readouterr() assert not out - assert 'can not write' in err + assert 'Can not write' in err |
