summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-10-12 08:03:14 +0200
committerNed Batchelder <ned@nedbatchelder.com>2021-10-12 05:57:35 -0400
commitce0e38e131e987c1bba1dd51abb2d4a002ac3c4e (patch)
tree84cf23552169281caf6b2584998c6be4296acc1e /tests
parent73ca4596fc8eed9c76714e7a5c80dd61d71fe1b1 (diff)
downloadpython-coveragepy-git-ce0e38e131e987c1bba1dd51abb2d4a002ac3c4e.tar.gz
fix: find_writable_pth_directory must expect failure from open()
Fix find_writable_pth_directory() to expect the OSError from the open() call. In general, this is what's going to happen if the file is not writable. The current logic could only be triggered e.g. if the file was writable but the underlying filesystem run out of space.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_process.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_process.py b/tests/test_process.py
index 63dd1d5b..a3135049 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -1419,11 +1419,11 @@ def find_writable_pth_directory():
"""Find a place to write a .pth file."""
for pth_dir in possible_pth_dirs(): # pragma: part covered
try_it = os.path.join(pth_dir, f"touch_{WORKER}.it")
- with open(try_it, "w") as f:
- try:
+ try:
+ with open(try_it, "w") as f:
f.write("foo")
- except OSError: # pragma: cant happen
- continue
+ except OSError: # pragma: cant happen
+ continue
os.remove(try_it)
return pth_dir