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

Function test_subclass_compatibility

tests/test_filelock.py:790–821  ·  view source on GitHub ↗
(tmp_path: Path)

Source from the content-addressed store, hash-verified

788
789
790def test_subclass_compatibility(tmp_path: Path) -> None:
791 class MyFileLock(FileLock):
792 def __init__(
793 self,
794 lock_file: str | os.PathLike[str],
795 timeout: float = -1,
796 mode: int = 0o644,
797 thread_local: bool = True,
798 my_param: int = 0,
799 **kwargs: dict[str, Any], # ruff:ignore[unused-method-argument] # matches the base constructor signature; extras are dropped
800 ) -> None:
801 super().__init__(lock_file, timeout, mode, thread_local, is_singleton=True)
802 self.blocking = True
803 self.my_param = my_param
804
805 lock_path = tmp_path / "a"
806 MyFileLock(str(lock_path), my_param=1)
807
808 class MySoftFileLock(SoftFileLock):
809 def __init__(
810 self,
811 lock_file: str | os.PathLike[str],
812 timeout: float = -1,
813 mode: int = 0o644,
814 thread_local: bool = True,
815 my_param: int = 0,
816 **kwargs: dict[str, Any], # ruff:ignore[unused-method-argument] # matches the base constructor signature; extras are dropped
817 ) -> None:
818 super().__init__(lock_file, timeout, mode, thread_local, blocking=True, is_singleton=True)
819 self.my_param = my_param
820
821 MySoftFileLock(str(lock_path), my_param=1)
822
823
824@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