pytestCheckHook: support __structuredAttrs

Add flag pytestFlags as the new, conforming interface
replacing pytestFlagsArray.

Stop Bash-expanding disabledTests and disabledTestPaths.

Handle disabledTestPaths with `pytest --ignore-glob <path>`
to keep globbing support.
Check if each path glob matches at least one path
using the `glob` module from the Python standard library.

Also make buildPythonPackage and buildPythonApplication
stop escaping the elements of disabledTests and disabledTestPaths.
This commit is contained in:
Yueh-Shun Li 2024-10-09 18:14:29 +08:00
parent e8f3fe8c6e
commit 26f09762a8
3 changed files with 40 additions and 24 deletions

View file

@ -1273,7 +1273,7 @@ Using the example above, the analogous `pytestCheckHook` usage would be:
];
# requires additional data
pytestFlagsArray = [
pytestFlags = [
"tests/"
"--ignore=tests/integration"
];
@ -2002,7 +2002,7 @@ Occasionally packages don't make use of a common test framework, which may then
* Non-working tests can often be deselected. Most Python modules
do follow the standard test protocol where the pytest runner can be used.
`pytest` supports the `-k` and `--ignore` parameters to ignore test
`pytest` supports the `-k` and `--ignore-glob` parameters to ignore test
methods or classes as well as whole files. For `pytestCheckHook` these are
conveniently exposed as `disabledTests` and `disabledTestPaths` respectively.
@ -2019,11 +2019,17 @@ Occasionally packages don't make use of a common test framework, which may then
];
disabledTestPaths = [
"this/file.py"
"path/to/performance.py"
"path/to/connect-*.py"
];
}
```
::: {.note}
If the test path to disable contains characters like `*`, `?`, `[`, and `]`,
quote them with square brackets (`[*]`, `[?]`, `[[]`, and `[]]`) to match literally.
:::
* Tests that attempt to access `$HOME` can be fixed by using the following
work-around before running tests (e.g. `preCheck`): `export HOME=$(mktemp -d)`
* Compiling with Cython causes tests to fail with a `ModuleNotLoadedError`.