Skip to content

Commit 0023f11

Browse files
authored
docs: add uv and doctest suggested configuration and setup (#20)
1 parent c05923d commit 0023f11

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/testing.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,46 @@ addopts = [
6868
]
6969
```
7070

71+
##### uv and the TDD Theme
72+
The way Python paths are resolved sometimes differ between the Package & Dependency management tools
73+
out there. For `uv` you might need to configure `pytest` to find the __TDD Theme__ specific paths.
74+
__NOTE__: this is not needed for the recommended _loose_ theme.
75+
76+
``` python
77+
# running pytest with uv and the TDD theme
78+
79+
# conftest.py
80+
81+
import sys
82+
from pathlib import Path
83+
84+
85+
def pytest_configure(config):
86+
bases = Path.cwd().glob("bases/**/**/src")
87+
components = Path.cwd().glob("components/**/**/src")
88+
89+
paths = list(bases) + list(components)
90+
91+
for path in paths:
92+
sys.path.insert(0, path.as_posix())
93+
```
94+
95+
### Running doctests
96+
`pytest` has a relatively new feature called _consider_namespace_packages_.
97+
This feature is useful when running _doctests_.
98+
99+
Suggested `pytest` configuration to run the regular tests and also doctests:
100+
101+
``` toml
102+
[tool.pytest.ini_options]
103+
addopts = [
104+
"--import-mode=importlib",
105+
"--doctest-modules",
106+
]
107+
consider_namespace_packages = true
108+
```
109+
110+
71111
### Running tests for changed code
72112
You can use `poly diff` in combination with your favorite test runner,
73113
to only run the corresponding tests for changed code.

0 commit comments

Comments
 (0)