Skip to content

Commit 0ed74c7

Browse files
committed
Another try to fix the appveyor on windows permission issue
1 parent 9b0a3c9 commit 0ed74c7

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/test_history.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,16 +459,18 @@ def hist_file():
459459
pass
460460

461461
def test_bad_history_file_path(capsys, request):
462-
with tempfile.TemporaryDirectory() as test_dir:
463-
# For appveyor, create a directory in our temp dir
464-
# for some reason it seems that appveyor won't let us read
465-
# the directory we created
466-
safe_dir = os.path.join(test_dir, 'somedir')
467-
os.mkdir(safe_dir)
468-
# Create a new cmd2 app
469-
cmd2.Cmd(persistent_history_file=safe_dir)
470-
_, err = capsys.readouterr()
471-
assert 'is a directory' in err
462+
# can't use tempfile.TemporaryDirectory() as a context on Appveyor
463+
# on windows. it causes a file locking issue which is reflected as
464+
# a permission exception
465+
test_dir = tempfile.mkdtemp()
466+
# Create a new cmd2 app
467+
cmd2.Cmd(persistent_history_file=test_dir)
468+
_, err = capsys.readouterr()
469+
assert 'is a directory' in err
470+
try:
471+
os.rmdir(test_dir)
472+
except OSError:
473+
pass
472474

473475
def test_history_file_conversion_no_truncate_on_init(hist_file, capsys):
474476
# test the code that converts a plain text history file to a pickle binary

0 commit comments

Comments
 (0)