pytest-resources 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. pytest_resources-0.1.0/.gitignore +218 -0
  2. pytest_resources-0.1.0/CHANGELOG.md +39 -0
  3. pytest_resources-0.1.0/LICENSE +21 -0
  4. pytest_resources-0.1.0/PKG-INFO +139 -0
  5. pytest_resources-0.1.0/README.md +113 -0
  6. pytest_resources-0.1.0/pyproject.toml +158 -0
  7. pytest_resources-0.1.0/src/pytest_resources/__init__.py +36 -0
  8. pytest_resources-0.1.0/src/pytest_resources/errors.py +13 -0
  9. pytest_resources-0.1.0/src/pytest_resources/formats.py +67 -0
  10. pytest_resources-0.1.0/src/pytest_resources/hooks.py +44 -0
  11. pytest_resources-0.1.0/src/pytest_resources/index.py +92 -0
  12. pytest_resources-0.1.0/src/pytest_resources/loaders.py +77 -0
  13. pytest_resources-0.1.0/src/pytest_resources/nodes.py +206 -0
  14. pytest_resources-0.1.0/src/pytest_resources/plugin.py +68 -0
  15. pytest_resources-0.1.0/src/pytest_resources/py.typed +1 -0
  16. pytest_resources-0.1.0/tests/integration/test_library.py +79 -0
  17. pytest_resources-0.1.0/tests/resources/binary/blob.dat +1 -0
  18. pytest_resources-0.1.0/tests/resources/config/app.ini +3 -0
  19. pytest_resources-0.1.0/tests/resources/config/manifest.jsonc +5 -0
  20. pytest_resources-0.1.0/tests/resources/config/settings.toml +5 -0
  21. pytest_resources-0.1.0/tests/resources/data/movies.csv +3 -0
  22. pytest_resources-0.1.0/tests/resources/structured/nested/deep.json +1 -0
  23. pytest_resources-0.1.0/tests/resources/structured/sample.json +1 -0
  24. pytest_resources-0.1.0/tests/resources/structured/sample2.json +1 -0
  25. pytest_resources-0.1.0/tests/resources/unstructured/sample.md +3 -0
  26. pytest_resources-0.1.0/tests/resources/unstructured/sample2.md +3 -0
  27. pytest_resources-0.1.0/tests/unit/test_formats.py +31 -0
  28. pytest_resources-0.1.0/tests/unit/test_hook.py +77 -0
  29. pytest_resources-0.1.0/tests/unit/test_index.py +229 -0
  30. pytest_resources-0.1.0/tests/unit/test_init.py +25 -0
  31. pytest_resources-0.1.0/tests/unit/test_loaders.py +59 -0
  32. pytest_resources-0.1.0/tests/unit/test_plugin.py +98 -0
@@ -0,0 +1,218 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to **pytest-resources** are documented here.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/) and the project
5
+ adheres to [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2026-09-23
10
+
11
+ First release.
12
+
13
+ ### Added
14
+
15
+ - `resources` pytest fixture: a session-scoped, lazy index over one or more resource
16
+ directories, navigable as an attribute / item / iterable tree
17
+ (`r.a.b`, `r["a"]["b"]`, `list(r.a)`, `.keys()/.values()/.items()`, `in`, `len`).
18
+ - `FileType` (`StrEnum`) resolving extensions to canonical kinds through a frozen suffix
19
+ table; anything unknown resolves to `BINARY`.
20
+ - A pluggable loader table (`default_loaders`) that prefers
21
+ [`e-serde`](https://pypi.org/project/e-serde/) native codecs (JSON / JSONC / YAML / TOML /
22
+ INI) when installed and falls back to the standard library (`json` + `tomllib`); kinds
23
+ with no parser return raw `bytes`. e-serde is an optional `[serde]` extra, never a core
24
+ dependency.
25
+ - Extraction helpers on every node: `select` / `first` (filtered values), `paths` (file
26
+ paths), `walk` / `awalk` (recursive, sync and async), `similar` (fuzzy stem match),
27
+ `choice` (randomised pick) and `as_dict` (nested dict export).
28
+ - Root configuration: `--resources-root` (repeatable), the `resources_root` ini list, and
29
+ the `pytest_resources_roots` hook for contributions; multiple roots are merged into one
30
+ tree, with the later root winning a top-level clash. The fixture creates a missing root;
31
+ the programmatic API stays strict.
32
+ - A `pytest_resource_loaders(register)` hook to bind or override any codec declaratively.
33
+ - Programmatic `build_resources` / `abuild_resources` (sync and off-the-loop), each taking a
34
+ single path or a sequence of paths.
35
+ - A module-lifetime decode cache per tree, and typed misses (`EntryNotFoundError` /
36
+ `KeyError`) that carry a `difflib` "did you mean" hint.
37
+
38
+ [unreleased]: https://github.com/damvolkov/pytest-resources/compare/v0.1.0...HEAD
39
+ [0.1.0]: https://github.com/damvolkov/pytest-resources/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Damien Volkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.5
2
+ Name: pytest-resources
3
+ Version: 0.1.0
4
+ Summary: Lazy, typed, attribute-navigable fixtures for test resource files, with pluggable canonical loaders (e-serde by default).
5
+ Project-URL: Homepage, https://github.com/damvolkov/pytest-resources
6
+ Project-URL: Source, https://github.com/damvolkov/pytest-resources
7
+ Project-URL: Issues, https://github.com/damvolkov/pytest-resources/issues
8
+ Project-URL: Changelog, https://github.com/damvolkov/pytest-resources/blob/main/CHANGELOG.md
9
+ Author-email: damvolkov <damvolkovv@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: config,e-serde,fixtures,json,pytest,pytest-plugin,resources,testing,toml,yaml
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.14
22
+ Requires-Dist: pytest>=8.0
23
+ Provides-Extra: serde
24
+ Requires-Dist: e-serde<0.3,>=0.2.0; extra == 'serde'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # pytest-resources
28
+
29
+ Lazy, typed, attribute-navigable fixtures for test resource files — JSON / JSONC / YAML /
30
+ TOML / INI decoded through [`e-serde`](https://pypi.org/project/e-serde/) by default,
31
+ extensible to **any** canonical `bytes -> object` loader, and anything else handed back as
32
+ raw `bytes`.
33
+
34
+ You point it at one or more directories of sample files; it recursively indexes the tree
35
+ without reading anything, and you reach, filter and randomise parsed values the way they
36
+ read:
37
+
38
+ ```python
39
+ import pytest_resources as pr
40
+
41
+ def test_profile(resources: pr.Resources):
42
+ user = resources.structured.user # sample dir -> dict (decoded, cached)
43
+ body = resources.unstructured.intro # a .md -> str
44
+ blob = resources.binary.logo # no codec bound -> raw bytes
45
+
46
+ jsons = resources.data.select("*.json") # filter a folder (glob / regex / kind)
47
+ pick = resources.data.choice("*.json") # random pick, seeded per run
48
+ ```
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ uv add --group test "pytest-resources[serde]" # e-serde default codecs
54
+ uv add --group test pytest-resources # stdlib-only (json + tomllib)
55
+ ```
56
+
57
+ The `resources` fixture auto-loads via the `pytest11` entry point — no imports in your
58
+ `conftest.py`.
59
+
60
+ ## What you get
61
+
62
+ | Idea | Mechanism |
63
+ |---|---|
64
+ | **Recursive index, zero read** | each root is walked once (off the loop); only paths are held |
65
+ | **Lazy + cached** | a file decodes on first access and is memoized for the session |
66
+ | **Attr / item / iter views** | `r.a.b`, `r["a"]["b"]`, `list(r.a)` → list of decoded values |
67
+ | **Extract from a folder** | `select`/`first` · `paths` · `walk`/`awalk` (sync/async, lazy) · `similar` (fuzzy) · `as_dict`, by glob / regex / `kind` |
68
+ | **Randomise the pick** | `r.a.choice(...)` (session-seeded) or pass your own `rng` |
69
+ | **Typed by suffix** | `FileType` (`StrEnum`) resolves the extension; the loader table decodes |
70
+ | **Open-ended fallback** | `CSV`/`TSV`/`PDF`/… and any unknown kind stay raw `bytes` |
71
+ | **Many roots, one tree** | CLI / ini / `pytest_resources_roots` hook, merged (later wins), auto-created |
72
+ | **Pluggable codecs** | override or add any kind through the `pytest_resource_loaders` hook |
73
+ | **e-serde default, optional** | native Rust/C config codecs when installed; stdlib otherwise |
74
+ | **Friendly misses** | `EntryNotFoundError` / `KeyError` carry a "did you mean" hint |
75
+
76
+ ## Configuring the roots
77
+
78
+ By default the plugin indexes `<rootdir>/tests/resources` (and **creates it if missing**).
79
+ Point it at one or several directories:
80
+
81
+ ```toml
82
+ # pyproject.toml
83
+ [tool.pytest.ini_options]
84
+ resources_root = ["fixtures", "fixtures/shared"] # default: <rootdir>/tests/resources
85
+ ```
86
+
87
+ Or per run (`--resources-root` is repeatable), or additively from your `conftest.py`:
88
+
89
+ ```python
90
+ from pathlib import Path
91
+
92
+ def pytest_resources_roots(roots):
93
+ roots.append(Path("tests/fixtures/shared"))
94
+ ```
95
+
96
+ CLI wins over ini, which wins over the default. Every resolved root is merged into one
97
+ navigable tree; on a top-level clash the **later** root wins.
98
+
99
+ ## Custom loaders (the extension seam)
100
+
101
+ The plugin never assumes e-serde. Bind any parser declaratively in your `conftest.py`:
102
+
103
+ ```python
104
+ from pytest_resources import FileType
105
+ import yaml, csv, io
106
+
107
+ def pytest_resource_loaders(register):
108
+ register({FileType.CSV: lambda b: list(csv.DictReader(io.StringIO(b.decode())))})
109
+ register({FileType.YAML: yaml.safe_load})
110
+ ```
111
+
112
+ `register` merges into the session's table, so you can override a default kind as easily
113
+ as add an unknown one. Kinds left unbound hand back **raw bytes**.
114
+
115
+ ## Programmatic use
116
+
117
+ Outside pytest, build a tree yourself:
118
+
119
+ ```python
120
+ from pathlib import Path
121
+ import pytest_resources as pr
122
+
123
+ tree = pr.build_resources(Path("fixtures")) # sync, one root
124
+ tree = pr.build_resources([Path("a"), Path("b")]) # merged roots, later wins
125
+ tree = await pr.abuild_resources(Path("fixtures")) # off the event loop
126
+ table = pr.default_loaders() # best available codecs
127
+ ```
128
+
129
+ ## Development
130
+
131
+ ```bash
132
+ make install # uv sync + git hooks
133
+ make check # ruff + ty + tach + validate + tests
134
+ make ci # everything the pipeline runs (adds coverage gate + docs + zizmor)
135
+ ```
136
+
137
+ ## License
138
+
139
+ MIT
@@ -0,0 +1,113 @@
1
+ # pytest-resources
2
+
3
+ Lazy, typed, attribute-navigable fixtures for test resource files — JSON / JSONC / YAML /
4
+ TOML / INI decoded through [`e-serde`](https://pypi.org/project/e-serde/) by default,
5
+ extensible to **any** canonical `bytes -> object` loader, and anything else handed back as
6
+ raw `bytes`.
7
+
8
+ You point it at one or more directories of sample files; it recursively indexes the tree
9
+ without reading anything, and you reach, filter and randomise parsed values the way they
10
+ read:
11
+
12
+ ```python
13
+ import pytest_resources as pr
14
+
15
+ def test_profile(resources: pr.Resources):
16
+ user = resources.structured.user # sample dir -> dict (decoded, cached)
17
+ body = resources.unstructured.intro # a .md -> str
18
+ blob = resources.binary.logo # no codec bound -> raw bytes
19
+
20
+ jsons = resources.data.select("*.json") # filter a folder (glob / regex / kind)
21
+ pick = resources.data.choice("*.json") # random pick, seeded per run
22
+ ```
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ uv add --group test "pytest-resources[serde]" # e-serde default codecs
28
+ uv add --group test pytest-resources # stdlib-only (json + tomllib)
29
+ ```
30
+
31
+ The `resources` fixture auto-loads via the `pytest11` entry point — no imports in your
32
+ `conftest.py`.
33
+
34
+ ## What you get
35
+
36
+ | Idea | Mechanism |
37
+ |---|---|
38
+ | **Recursive index, zero read** | each root is walked once (off the loop); only paths are held |
39
+ | **Lazy + cached** | a file decodes on first access and is memoized for the session |
40
+ | **Attr / item / iter views** | `r.a.b`, `r["a"]["b"]`, `list(r.a)` → list of decoded values |
41
+ | **Extract from a folder** | `select`/`first` · `paths` · `walk`/`awalk` (sync/async, lazy) · `similar` (fuzzy) · `as_dict`, by glob / regex / `kind` |
42
+ | **Randomise the pick** | `r.a.choice(...)` (session-seeded) or pass your own `rng` |
43
+ | **Typed by suffix** | `FileType` (`StrEnum`) resolves the extension; the loader table decodes |
44
+ | **Open-ended fallback** | `CSV`/`TSV`/`PDF`/… and any unknown kind stay raw `bytes` |
45
+ | **Many roots, one tree** | CLI / ini / `pytest_resources_roots` hook, merged (later wins), auto-created |
46
+ | **Pluggable codecs** | override or add any kind through the `pytest_resource_loaders` hook |
47
+ | **e-serde default, optional** | native Rust/C config codecs when installed; stdlib otherwise |
48
+ | **Friendly misses** | `EntryNotFoundError` / `KeyError` carry a "did you mean" hint |
49
+
50
+ ## Configuring the roots
51
+
52
+ By default the plugin indexes `<rootdir>/tests/resources` (and **creates it if missing**).
53
+ Point it at one or several directories:
54
+
55
+ ```toml
56
+ # pyproject.toml
57
+ [tool.pytest.ini_options]
58
+ resources_root = ["fixtures", "fixtures/shared"] # default: <rootdir>/tests/resources
59
+ ```
60
+
61
+ Or per run (`--resources-root` is repeatable), or additively from your `conftest.py`:
62
+
63
+ ```python
64
+ from pathlib import Path
65
+
66
+ def pytest_resources_roots(roots):
67
+ roots.append(Path("tests/fixtures/shared"))
68
+ ```
69
+
70
+ CLI wins over ini, which wins over the default. Every resolved root is merged into one
71
+ navigable tree; on a top-level clash the **later** root wins.
72
+
73
+ ## Custom loaders (the extension seam)
74
+
75
+ The plugin never assumes e-serde. Bind any parser declaratively in your `conftest.py`:
76
+
77
+ ```python
78
+ from pytest_resources import FileType
79
+ import yaml, csv, io
80
+
81
+ def pytest_resource_loaders(register):
82
+ register({FileType.CSV: lambda b: list(csv.DictReader(io.StringIO(b.decode())))})
83
+ register({FileType.YAML: yaml.safe_load})
84
+ ```
85
+
86
+ `register` merges into the session's table, so you can override a default kind as easily
87
+ as add an unknown one. Kinds left unbound hand back **raw bytes**.
88
+
89
+ ## Programmatic use
90
+
91
+ Outside pytest, build a tree yourself:
92
+
93
+ ```python
94
+ from pathlib import Path
95
+ import pytest_resources as pr
96
+
97
+ tree = pr.build_resources(Path("fixtures")) # sync, one root
98
+ tree = pr.build_resources([Path("a"), Path("b")]) # merged roots, later wins
99
+ tree = await pr.abuild_resources(Path("fixtures")) # off the event loop
100
+ table = pr.default_loaders() # best available codecs
101
+ ```
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ make install # uv sync + git hooks
107
+ make check # ruff + ty + tach + validate + tests
108
+ make ci # everything the pipeline runs (adds coverage gate + docs + zizmor)
109
+ ```
110
+
111
+ ## License
112
+
113
+ MIT
@@ -0,0 +1,158 @@
1
+ ##### BUILD #####
2
+ [build-system]
3
+ requires = ["hatchling>=1.32", "uv-dynamic-versioning>=0.14"]
4
+ build-backend = "hatchling.build"
5
+
6
+ ##### PROJECT #####
7
+ [project]
8
+ name = "pytest-resources"
9
+ dynamic = ["version"]
10
+ description = "Lazy, typed, attribute-navigable fixtures for test resource files, with pluggable canonical loaders (e-serde by default)."
11
+ readme = "README.md"
12
+ requires-python = ">=3.14"
13
+ license = "MIT"
14
+ license-files = ["LICEN[CS]E*"]
15
+ authors = [{ name = "damvolkov", email = "damvolkovv@gmail.com" }]
16
+ keywords = ["pytest", "pytest-plugin", "fixtures", "resources", "config", "e-serde", "json", "yaml", "toml", "testing"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Framework :: Pytest",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Software Development :: Testing",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = ["pytest>=8.0"]
28
+
29
+ [project.optional-dependencies]
30
+ serde = ["e-serde>=0.2.0,<0.3"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/damvolkov/pytest-resources"
34
+ Source = "https://github.com/damvolkov/pytest-resources"
35
+ Issues = "https://github.com/damvolkov/pytest-resources/issues"
36
+ Changelog = "https://github.com/damvolkov/pytest-resources/blob/main/CHANGELOG.md"
37
+
38
+ [project.entry-points."pytest11"]
39
+ resources = "pytest_resources.plugin"
40
+
41
+ ##### DEPS #####
42
+ [dependency-groups]
43
+ lint = [
44
+ "ruff>=0.16",
45
+ "ty>=0.0.75",
46
+ "tach>=0.35",
47
+ "validate-pyproject[all]>=0.26",
48
+ "zizmor>=1.25",
49
+ ]
50
+ test = [
51
+ "pytest>=9.1",
52
+ "pytest-asyncio>=1.4",
53
+ "pytest-cov>=7.1",
54
+ "pytest-randomly>=5.0",
55
+ "pytest-timeout>=2.4",
56
+ "e-serde>=0.2.0,<0.3",
57
+ ]
58
+ docs = [
59
+ "mkdocs-gen-files>=0.6",
60
+ "mkdocs-literate-nav>=0.6",
61
+ "mkdocs-material>=9.7",
62
+ "mkdocs-section-index>=0.3",
63
+ "mkdocstrings[python]>=1.0",
64
+ ]
65
+ dev = [
66
+ { include-group = "lint" },
67
+ { include-group = "test" },
68
+ { include-group = "docs" },
69
+ "prek>=0.4",
70
+ ]
71
+
72
+ [tool.uv]
73
+ required-version = ">=0.12"
74
+ default-groups = ["dev"]
75
+ exclude-newer = "7 days"
76
+ ### e-serde is first-party and can publish same-day; exempt only it from the freshness guard.
77
+ exclude-newer-package = { e-serde = "1 hour" }
78
+ cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true } }]
79
+
80
+ ##### VERSION #####
81
+ [tool.hatch.version]
82
+ source = "uv-dynamic-versioning"
83
+
84
+ [tool.uv-dynamic-versioning]
85
+ vcs = "git"
86
+ style = "pep440"
87
+ bump = true
88
+ fallback-version = "0.1.0"
89
+
90
+ [tool.hatch.build.targets.wheel]
91
+ packages = ["src/pytest_resources"]
92
+
93
+ [tool.hatch.build.targets.sdist]
94
+ include = ["src/", "tests/", "README.md", "CHANGELOG.md"]
95
+
96
+ ##### LINT #####
97
+ [tool.ruff]
98
+ line-length = 120
99
+ target-version = "py314"
100
+ src = ["src", "tests"]
101
+
102
+ [tool.ruff.lint]
103
+ select = [
104
+ "F", "E", "W", "I", "N", "UP", "B", "A", "C4", "DTZ", "T10", "T20", "EM", "ISC",
105
+ "PIE", "PT", "RET", "SIM", "TID", "TC", "ARG", "PTH", "PL", "PERF", "FURB",
106
+ "ASYNC", "S", "BLE", "FBT", "LOG", "G", "RUF",
107
+ ]
108
+ ignore = ["E501", "ISC001", "PLR0913"]
109
+
110
+ [tool.ruff.lint.per-file-ignores]
111
+ "tests/**" = ["S101", "PLR2004", "ARG", "FBT", "S311"]
112
+
113
+ [tool.ruff.lint.isort]
114
+ known-first-party = ["pytest_resources", "tests"]
115
+
116
+ [tool.ruff.lint.flake8-tidy-imports]
117
+ ban-relative-imports = "all"
118
+
119
+ [tool.ruff.format]
120
+ docstring-code-format = true
121
+
122
+ ##### TYPES #####
123
+ [tool.ty.environment]
124
+ python-version = "3.14"
125
+
126
+ [tool.ty.src]
127
+ include = ["src", "tests"]
128
+
129
+ [tool.ty.terminal]
130
+ error-on-warning = true
131
+
132
+ ##### TEST #####
133
+ [tool.pytest]
134
+ minversion = "9.0"
135
+ testpaths = ["tests"]
136
+ ### Block the pytest11 entry point so the plugin loads from conftest *after* coverage
137
+ ### starts (see tests/conftest.py); otherwise it is imported at startup and unmeasurable.
138
+ addopts = ["--import-mode=importlib", "-ra", "-p", "no:resources"]
139
+ strict = true
140
+ filterwarnings = ["error"]
141
+ timeout = "60"
142
+ asyncio_mode = "auto"
143
+ asyncio_default_fixture_loop_scope = "session"
144
+ markers = ["slow: slow tests (deselect with -m 'not slow')"]
145
+
146
+ ##### COVERAGE #####
147
+ [tool.coverage.run]
148
+ ### Path source, not source_pkgs: a pytest11 plugin is imported at startup, before
149
+ ### coverage starts; package-name resolution then marks it "not measured".
150
+ source = ["src/pytest_resources"]
151
+ branch = true
152
+ parallel = true
153
+
154
+ [tool.coverage.report]
155
+ fail_under = 90
156
+ show_missing = true
157
+ skip_covered = true
158
+ exclude_also = ["if TYPE_CHECKING:", "@overload", "raise NotImplementedError", '^\s*\.\.\.$']