diff options
author | David Szotten <davidszotten@gmail.com> | 2016-02-03 20:58:32 +0000 |
---|---|---|
committer | David Szotten <davidszotten@gmail.com> | 2016-02-03 20:58:32 +0000 |
commit | 43a13ba06557ec109ab723d5e084878942ea6386 (patch) | |
tree | e65c788affda99e1b1a3dbd6fc8f7b004fc705ea /tests/test_main.py | |
parent | bea392d7ed263ceec5d81311a9f116e0fcd4574f (diff) |
a few more tests
Diffstat (limited to 'tests/test_main.py')
-rw-r--r-- | tests/test_main.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/tests/test_main.py b/tests/test_main.py index 4a91f541..a30d1164 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,5 +1,6 @@ import os import platform +import stat import pytest try: @@ -77,10 +78,26 @@ def test_i_works(tmpdir, executor): run(executor, statement, pgspecial=cli.pgspecial) +def test_existing_rc_dir(tmpdir): + rcfile = str(tmpdir.mkdir("subdir").join("rcfile")) + + PGCli(pgclirc_file=rcfile) + assert os.path.exists(rcfile) + + def test_missing_rc_dir(tmpdir): rcfile = str(tmpdir.join("subdir").join("rcfile")) - cli = PGCli( - pgclirc_file=rcfile, - ) + PGCli(pgclirc_file=rcfile) assert os.path.exists(rcfile) + + +def test_other_rcdir_create_error(tmpdir): + subdir = tmpdir.join("subdir") + rcfile = subdir.join("rcfile") + + # trigger an oserror that isn't "directory already exists" + os.chmod(str(tmpdir), stat.S_IREAD) + + with pytest.raises(OSError): + PGCli(pgclirc_file=str(rcfile)) |