Debian Codegraph @

testing/example_scripts/customdirectory/conftest.py

raw
1 # mypy: allow-untyped-defs
2 # content of conftest.py
3 from __future__ import annotations
4
5 import json
6
7 import pytest
8
9
10 class ManifestDirectory(pytest.Directory):
11 def collect(self):
12 manifest_path = self.path / "manifest.json"
13 manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
14 ihook = self.ihook
15 for file in manifest["files"]:
16 yield from ihook.pytest_collect_file(
17 file_path=self.path / file, parent=self
18 )
19
20
21 @pytest.hookimpl
22 def pytest_collect_directory(path, parent):
23 if path.joinpath("manifest.json").is_file():
24 return ManifestDirectory.from_parent(parent=parent, path=path)
25 return None