(
lock_type: type[BaseFileLock],
path_type: type[str | Path],
filename: str,
tmp_path: Path,
caplog: pytest.LogCaptureFixture,
)
| 28 | @pytest.mark.parametrize("path_type", [str, PurePath, Path]) |
| 29 | @pytest.mark.parametrize("filename", ["a", "new/b", "new2/new3/c"]) |
| 30 | def test_simple( |
| 31 | lock_type: type[BaseFileLock], |
| 32 | path_type: type[str | Path], |
| 33 | filename: str, |
| 34 | tmp_path: Path, |
| 35 | caplog: pytest.LogCaptureFixture, |
| 36 | ) -> None: |
| 37 | caplog.set_level(logging.DEBUG) |
| 38 | |
| 39 | # test lock creation by passing a `str` |
| 40 | lock_path = tmp_path / filename |
| 41 | lock = lock_type(path_type(lock_path)) |
| 42 | with lock as locked: |
| 43 | assert lock.is_locked |
| 44 | assert lock is locked |
| 45 | assert not lock.is_locked |
| 46 | |
| 47 | assert caplog.messages == [ |
| 48 | f"Attempting to acquire lock {id(lock)} on {lock_path}", |
| 49 | f"Lock {id(lock)} acquired on {lock_path}", |
| 50 | f"Attempting to release lock {id(lock)} on {lock_path}", |
| 51 | f"Lock {id(lock)} released on {lock_path}", |
| 52 | ] |
| 53 | assert [r.levelno for r in caplog.records] == [logging.DEBUG, logging.DEBUG, logging.DEBUG, logging.DEBUG] |
| 54 | assert [r.name for r in caplog.records] == ["filelock", "filelock", "filelock", "filelock"] |
| 55 | assert logging.getLogger("filelock").level == logging.NOTSET |
| 56 | |
| 57 | |
| 58 | @contextmanager |
nothing calls this directly
no outgoing calls
no test coverage detected