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

Function test_subclass_compatibility

tests/core/test_singleton.py:70–101  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

68
69
70def test_subclass_compatibility(tmp_path: Path) -> None:
71 class MyFileLock(FileLock):
72 def __init__(
73 self,
74 lock_file: str | os.PathLike[str],
75 timeout: float = -1,
76 mode: int = 0o644,
77 thread_local: bool = True,
78 my_param: int = 0,
79 **kwargs: dict[str, Any], # ruff:ignore[unused-method-argument] # matches the base constructor signature; extras are dropped
80 ) -> None:
81 super().__init__(lock_file, timeout, mode, thread_local, is_singleton=True)
82 self.blocking = True
83 self.my_param = my_param
84
85 lock_path = tmp_path / "a"
86 MyFileLock(str(lock_path), my_param=1)
87
88 class MySoftFileLock(SoftFileLock):
89 def __init__(
90 self,
91 lock_file: str | os.PathLike[str],
92 timeout: float = -1,
93 mode: int = 0o644,
94 thread_local: bool = True,
95 my_param: int = 0,
96 **kwargs: dict[str, Any], # ruff:ignore[unused-method-argument] # matches the base constructor signature; extras are dropped
97 ) -> None:
98 super().__init__(lock_file, timeout, mode, thread_local, blocking=True, is_singleton=True)
99 self.my_param = my_param
100
101 MySoftFileLock(str(lock_path), my_param=1)
102
103
104@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])

Callers

nothing calls this directly

Calls 2

MyFileLockClass · 0.85
MySoftFileLockClass · 0.85

Tested by

no test coverage detected