Testing Contracts API
pathlib_next.testing
Test-suite building blocks for verifying custom Path/UriPath implementations satisfy the library's filesystem contract.
Not imported by pathlib_next/__init__.py -- this module requires pytest,
which is a test-only dependency. Import it explicitly:
from pathlib_next.testing import PathContract
class TestMyPath(PathContract):
@pytest.fixture
def root(self, tmp_path):
return MyPath(tmp_path)
PathContract
Bases: ReadPathContract
Mixin of filesystem-contract tests every writable Path implementation
(custom Path subclass, or UriPath scheme) must satisfy.
Subclasses must provide a root fixture pointing to a writable directory
pre-populated with the standard fixture_tree (see conftest.py).
Note: ftp/dav/s3 stay mock-unit-only because their hand-rolled fakes aren't faithful enough for a generic contract.
PurePathContract
Contract tests for pure path (logical) operations, not requiring any I/O.
ReadPathContract
Bases: PurePathContract
Contract tests for read-only path operations.
Subclasses must provide a root fixture pointing to a directory pre-populated
with the standard fixture_tree (see conftest.py):
- a.txt (content: "a")
- b.py (content: "b")
- .hidden.txt (content: "hidden")
- sub/c.py (content: "c")
- sub/nested/d.py (content: "d")
- empty_dir/