From 43a13ba06557ec109ab723d5e084878942ea6386 Mon Sep 17 00:00:00 2001 From: David Szotten Date: Wed, 3 Feb 2016 20:58:32 +0000 Subject: a few more tests --- tests/test_main.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'tests/test_main.py') 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)) -- cgit v1.2.3