diff options
author | Yutian Li <hotpxless@gmail.com> | 2024-05-09 14:04:58 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-09 15:04:58 -0300 |
commit | 5af46f3d4e8264c50ffd635dbb395199670e70b7 (patch) | |
tree | 764905b793760865762037919cc2c920d8eb5d60 | |
parent | d49f1fc4dbf9e04da016335d9e82527423d9ad1f (diff) | |
download | pytest-upstream-main.tar.gz |
Fix crashing under squashfuse_ll read-only mounts (#12301)upstream-main
Fixes #12300
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | changelog/12300.bugfix.rst | 1 | ||||
-rw-r--r-- | src/_pytest/assertion/rewrite.py | 5 | ||||
-rw-r--r-- | testing/test_assertrewrite.py | 5 |
4 files changed, 11 insertions, 1 deletions
@@ -441,6 +441,7 @@ Yao Xiao Yoav Caspi Yuliang Shao Yusuke Kadowaki +Yutian Li Yuval Shimon Zac Hatfield-Dodds Zachary Kneupper diff --git a/changelog/12300.bugfix.rst b/changelog/12300.bugfix.rst new file mode 100644 index 000000000..6c1624820 --- /dev/null +++ b/changelog/12300.bugfix.rst @@ -0,0 +1 @@ +Fixed handling of 'Function not implemented' error under squashfuse_ll, which is a different way to say that the mountpoint is read-only. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index b6f14aa92..3d5df0d6c 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -1171,7 +1171,10 @@ def try_makedirs(cache_dir: Path) -> bool: return False except OSError as e: # as of now, EROFS doesn't have an equivalent OSError-subclass - if e.errno == errno.EROFS: + # + # squashfuse_ll returns ENOSYS "OSError: [Errno 38] Function not + # implemented" for a read-only error + if e.errno in {errno.EROFS, errno.ENOSYS}: return False raise return True diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index bedf6e276..82c7055b9 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1972,6 +1972,11 @@ def test_try_makedirs(monkeypatch, tmp_path: Path) -> None: monkeypatch.setattr(os, "makedirs", partial(fake_mkdir, exc=err)) assert not try_makedirs(p) + err = OSError() + err.errno = errno.ENOSYS + monkeypatch.setattr(os, "makedirs", partial(fake_mkdir, exc=err)) + assert not try_makedirs(p) + # unhandled OSError should raise err = OSError() err.errno = errno.ECHILD |