MCPcopy Create free account
hub / github.com/tox-dev/filelock / deny_write

Function deny_write

tests/native/conftest.py:59–67  ·  view source on GitHub ↗
(path: str, flags: int, mode: int = 0o777, *, dir_fd: int | None = None)

Source from the content-addressed store, hash-verified

57 real_open = os.open
58
59 def deny_write(path: str, flags: int, mode: int = 0o777, *, dir_fd: int | None = None) -> int:
60 if not flags & os.O_CREAT and str(tmp_path / "test.lock") == path:
61 if flags & os.O_RDWR:
62 if behavior == "unlink":
63 (tmp_path / "test.lock").unlink()
64 raise PermissionError(EACCES, "Permission denied", path)
65 if behavior == "leased":
66 raise BlockingIOError(EWOULDBLOCK, "Resource temporarily unavailable", path)
67 return real_open(path, flags, mode, dir_fd=dir_fd)
68
69 mocker.patch("os.open", side_effect=deny_write, autospec=True)
70

Callers

nothing calls this directly

Calls 1

unlinkMethod · 0.45

Tested by

no test coverage detected