-
-
Notifications
You must be signed in to change notification settings - Fork 813
Closed
Description
New feature in pytest 9: https://docs.pytest.org/en/stable/changelog.html#pytest-9-0-0-2025-11-05
subtests are an alternative to parametrization, useful in situations where the parametrization values are not all known at collection time.
Example:
def contains_docstring(p: Path) -> bool: """Return True if the given Python file contains a top-level docstring.""" ... def test_py_files_contain_docstring(subtests: pytest.Subtests) -> None: for path in Path.cwd().glob("*.py"): with subtests.test(path=str(path)): assert contains_docstring(path)
Would be interesting to try these in test_docs.py.
Reactions are currently unavailable