test_dirstack::test_cdpath_expansion leaving stray dirs

This commit is contained in:
laerus 2016-09-21 14:45:58 +03:00
parent 2e5234da02
commit e2174dc34d
2 changed files with 21 additions and 7 deletions

13
news/test-dirstack.rst Normal file
View file

@ -0,0 +1,13 @@
**Added:** None
**Changed:** None
**Deprecated:** None
**Removed:** None
**Fixed:**
* test_dirstack test_cdpath_expansion leaving stray testing dirs
**Security:** None

View file

@ -59,13 +59,14 @@ def test_cdpath_expansion(xonsh_builtins):
os.path.expanduser("~/xonsh-test-cdpath-home")
)
try:
for _ in test_dirs:
if not os.path.exists(_):
os.mkdir(_)
assert os.path.exists(dirstack._try_cdpath(_)), "dirstack._try_cdpath: could not resolve {0}".format(_)
except Exception as e:
tuple(os.rmdir(_) for _ in test_dirs if os.path.exists(_))
raise e
for d in test_dirs:
if not os.path.exists(d):
os.mkdir(d)
assert os.path.exists(dirstack._try_cdpath(d)), "dirstack._try_cdpath: could not resolve {0}".format(d)
finally:
for d in test_dirs:
if os.path.exists(d):
os.rmdir(d)
def test_cdpath_events(xonsh_builtins, tmpdir):