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

Function interrupt_unix_create

tests/native/conftest.py:20–39  ·  view source on GitHub ↗
(
    lock: UnixFileLock, error: type[BaseException] = KeyboardInterrupt
)

Source from the content-addressed store, hash-verified

18
19
20def interrupt_unix_create(
21 lock: UnixFileLock, error: type[BaseException] = KeyboardInterrupt
22) -> None: # pragma: needs fcntl
23 def interrupt(
24 frame: FrameType, event: str, operation: BuiltinFunctionType | None
25 ) -> None: # pragma: no cover # profile hooks run with tracing disabled
26 if (
27 event == "c_return"
28 and frame.f_code.co_name == "open_into"
29 and (operation is os.open or getattr(operation, "__name__", None) == "extend")
30 ):
31 raise error
32
33 previous = sys.getprofile()
34 sys.setprofile(interrupt)
35 try:
36 with pytest.raises(error):
37 lock.acquire()
38 finally:
39 sys.setprofile(previous)
40
41
42@pytest.fixture

Calls 1

acquireMethod · 0.45

Tested by

no test coverage detected