Fix pytest_status workaround if .cache is missing

This commit is contained in:
Florian Bruhin 2016-05-29 22:21:35 +02:00
parent 2d9cf5ed3a
commit 8e2d315807

View File

@ -170,7 +170,14 @@ def pytest_sessionfinish(exitstatus):
"""Create a file to tell run_pytest.py how pytest exited."""
outcome = yield
outcome.get_result()
status_file = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..', '.cache', 'pytest_status')
cache_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
'..', '.cache')
try:
os.mkdir(cache_dir)
except FileExistsError:
pass
status_file = os.path.join(cache_dir, 'pytest_status')
with open(status_file, 'w', encoding='ascii') as f:
f.write(str(exitstatus))