pytest plugin to instrument tests
Project description
A pytest plugin to instrument tests and write the resulting records to file
Features
json file with one record for each setup/call/teardown of each test containing:
session id and record id (UUIDs generated by plugin)
node_id (pytest’s nodeid)
when (setup, call or teardown)
outcome (passed, failed or skipped)
start, stop and duration
labels (array) and tags (object) via @pytest.mark.instrument() decorator
fixtures
hooks to edit labels, tags and fixtures before the record is written to file
Requirements
Python 3.6 or higher
pytest 5.1.0 or higher
Installation
You can install “pytest-instrument” via pip from PyPI:
$ pip install pytest-instrument
Usage
Run your tests with:
$ pytest --instrument
An ./artifacts directory will be created if it doesn’t exist yet. For each pytest session one .json file will be written to that directory.
Hooks
pytest_instrument_labels: edit list of labels after they’ve been parsed by the plugin
pytest_instrument_tags: edit dictionary of tags after they’ve been parsed by the plugin
pytest_instrument_fixtures: edit list of fixtures after they’ve been parsed by the plugin
Changelog
Consult the changelog for fixes and enhancements of each version.
Issues/Requests
Please use the GitHub issue tracker to submit bugs or request features.
Contributing
Contributions are welcome. Tests can be run with tox, please ensure black code formatting and good test coverage before you submit a pull request.
License
Distributed under the terms of the MIT license, “pytest-instrument” is free and open source software
Acknowledgements
Thank you to Maaret Pyhäjärvi for inspiring this plugin by sharing the story of how her team started instrumenting tests at TestCraftCamp 2019.
This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-instrument-0.1.0.tar.gz
.
File metadata
- Download URL: pytest-instrument-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.22.0 CPython/2.7.15+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5e9e5e1798df1918eee53b3c84fb32a07df1dfd772ebe51db7a025c450b10b4 |
|
MD5 | fd9363f9085f602d20660b04a16ec6a2 |
|
BLAKE2b-256 | 8979a0cec4f35058397b980b396ffdaebd585bbb6aa67065de38b6093d37cfde |
File details
Details for the file pytest_instrument-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_instrument-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.22.0 CPython/2.7.15+
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2e2b6937b21f1037375fec687c5db107ea83e7af6b9a7121081989b3be24be |
|
MD5 | ffba2af54aa9d825c0950af5a1f99565 |
|
BLAKE2b-256 | 490cfb674235e94843fc1647cda85e04a44a8ac524c5c75570176ade98fa0150 |