livery.workshop._pytest_common¶
livery.workshop._pytest_common ¶
Pure-stdlib helpers shared by the workshop's pytest11 plugins.
Every pytest session in an environment with livery-workshop
installed loads its pytest11 entry points before any test runs.
Keeping these constants and path helpers in a leaf module with no
workshop imports keeps the workshop's module graph out of every
test session's startup and out of every test file's recorded reads.
Functions:
| Name | Description |
|---|---|
is_group |
Whether directory under |
package_directories |
List every directory under |
package_of |
Name the workspace package a test belongs to, from its pytest node id. |
Attributes:
| Name | Type | Description |
|---|---|---|
PACKAGES_DIR |
|
|
LEG_VARIABLE |
|
|
POINT_VARIABLE |
|
|
SPEED_FILE_VARIABLE |
|
|
PACKAGE_TREES |
|
is_group ¶
Whether directory under packages/ groups packages rather than being one.
A group has no workshop.toml of its own and at least one
subdirectory that has one. Groups do not nest.
Source code in packages/workshop/src/livery/workshop/_pytest_common.py
package_directories ¶
List every directory under packages/ that should hold a package.
A package lives at packages/<name>/ or, inside a group
directory, at packages/<group>/<name>/. A group is a directory
with no workshop.toml of its own and at least one subdirectory
that has one. The directories are listed whether or not they carry
a contract, and nothing in them is judged;
livery.workshop.discover_packages reads and judges the
contracts. Reach for this where a glob would assume one level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The workspace root. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The directories, sorted by path; empty when root has no |
...
|
|
Source code in packages/workshop/src/livery/workshop/_pytest_common.py
package_of ¶
Name the workspace package a test belongs to, from its pytest node id.
The package is the path before the first directory a package keeps
its tests or sources in, tests, src or docs:
packages/forge/tests/test_x.py::test_y belongs to
packages/forge. A package in a group directory is one level
deeper, and its own name may be one of those three: in
packages/extensions/docs/tests/test_x.py::test_y the tests
beneath docs says docs is the package, so the answer is
packages/extensions/docs. Nothing is read from the disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nodeid
|
str
|
A test's node id, relative to the workspace root. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The package's path relative to the workspace root, or |
str
|
a node outside |
str
|
|