A pytest plugin offering various functionality for Neural Magic’s Release Engineering team.
The Python package can be installed directly from this git repository from either a branch or tag:
# recommended: use a version tag (e.g., v0.1.0)
pip install https://github.com/neuralmagic/pytest-nm-releng/archive/v0.1.0.tar.gz
# alternative: install based on a branch (e.g., main)
pip install https://github.com/neuralmagic/pytest-nm-releng/archive/main.tar.gz
pytest-nm-releng
can automatically generate unique, dynamically-named JUnit report files with an optional prefix. The report file is generated when the test run begins using Python’s datetime.timestamp()
method (UTC).
Note
This works by appending the --junit-xml
flag after the command is run, meaning it will override any previously-specified instances of this flag.
To enable this behavior, define the environment variable NMRE_JUNIT_BASE
with a value to the path where the test files should be stored. This can be absolute or relative.
The following examples will both write JUnit report files in a folder named "test-results" in the current working directory.
# example: prefixing a command
NMRE_JUNIT_BASE=test-results pytest [...]
# example: export the environment variable (useful if pytest is not being
# invoked directly)
export NMRE_JUNIT_BASE=test-results
pytest [...]
# after either example, a file named something like
# `test-results/1735941024.348248.xml` will be created
Optionally, you can define NMRE_JUNIT_PREFIX
with a value to be prefixed onto the file name. Note that no separator is used so you may want to include one.
export NMRE_JUNIT_BASE=test-results
export NMRE_JUNIT_PREFIX="report-"
pytest [...]
# after either example, a file named something like
# `test-results/report-1735941218.338192.xml` will be created
pytest-nm-releng
can automatically add some code coverage flags as well (requires pytest-cov).
To enable this behavior, define the NMRE_COV_NAME
environment variable with a value of the project’s module name (e.g., the name that is used to import it within Python code).
# example: used with `nm-vllm-ent`, which is imported as `vllm`
NMRE_COV_NAME=vllm pytest [...]
# this will result in the following flags being appended:
# --cov=vllm --cov-append --cov-report=html:coverage-html --cov-report=json:coverage.json
To contribute, follow these general steps:
- Fork the repository
- Create a new branch
- Make your changes
- Install
tox
# example: using pipx pipx install tox # example: using uv uv tool install tox --with tox-uv
- Run quality checks and tests
# apply available automatic style/formatting fixes tox -e format # check style/formatting tox -e style # run tests tox -e py
- Submit a pull request with your changes
This pytest plugin was generated with Cookiecutter along with @hackebrot's cookiecutter-pytest-plugin template.