Pytest-stats
This library is collecting metadata about your test executions, and enables you to send it to a datastore of your liking.
Architecture
The library is designed in a hexagonal architecture in mind - separating data collection and reporting. There are two main parts to the code - metadata collection and reporting. the collection engine stores the metadata in pytest's stash (for session and for test) and uses pytest built-in hooks in order to populate the data and trigger the reporting. The reporting part is allowing reporters to register, then delegates the actual work to the registered reporters, enabling easy customization.
Implementation guide
In order to include pytest-stats capabilities in your code, all you need to do is to install the package pip install pytest-stats.
However, this will only provide you with a text report provided by the built-in DefaultTextReporter.
In order to store the data in your own DB you'll need to:
- Create a new reporter (inherit the abstract
ResultsReporterclass) - Register an instance of your reporter using the provided new hook
pytest_stats_register_reporters.
Example:
@pytest.hookimpl()
def pytest_stats_register_reporters(reporters:'ReportersRegistry'):
reporters.register(MyReporter())
Implementation details
how is data collected and reported?
Most data is collected by hooking the following pytest-provided hooks:
pytest_sessionstartpytest_sessionfinishpytest_runtest_protocolpytest_runtest_makereportpytest_exception_interact
New hooks available
pytest_stats_register_reporters: used to register a new reporter. More than one reporter can be registered at the same hook.
Invoked as part ofpytest_configurepytest_stats_env_data: Enables adding custom environment information to the session data.
Invoked as part ofpytest_sessionstart
Utility functions
get_test_session_data(session: 'Session') -> TestSessionData- can be used to fetch the session data in an arbitrary locationget_test_item_data(item: 'Item') -> TestItemData- can be used to fetch the current test data in arbitrary location. For instance, one can callget_test_item_data(item=request.node).foo="bar"
Metadata
Release files for pytest-stats 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytest_stats-1.0.1.tar.gz | 7.0 kB | Without provenance | Details for pytest_stats-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytest_stats-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for pytest_stats-1.0.1-py3-none-any.whl |
Total release size: 15.5 kB
Release files / pytest_stats-1.0.1.tar.gz
| Download URL | pytest_stats-1.0.1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5009d42c733cd67181dfea6f6fb88a63d3de7a4337a3509938c5adc74e176f2c
|
|
BLAKE2b-256 checksum How to use checksums |
dad1fb4305ecd01583472ccd8407d74846e9bcf8e84aa47427c2ca38a50142ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure
|
Release files / pytest_stats-1.0.1-py3-none-any.whl
| Download URL | pytest_stats-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47e04dc2bcb2922ede2ecf30b7e0ff8c34be491e8a76daa035d20d2f47f5ad6b
|
|
BLAKE2b-256 checksum How to use checksums |
ec6cc40a48e1238eb59bb65d9270aab64c62602bae6a474d2864ebca52b03615
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure
|
Security for pytest-stats 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.