Collects tests metadata for future analysis, easy to extend for any data store
Project description
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
ResultsReporter
class) - 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_sessionstart
pytest_sessionfinish
pytest_runtest_protocol
pytest_runtest_makereport
pytest_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_configure
pytest_stats_env_data
: Enables adding custom environment information to the session data.
Invoked as part ofpytest_sessionstart
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_stats-0.0.2.tar.gz
.
File metadata
- Download URL: pytest_stats-0.0.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c7776390aa8bb63f3490392533511fe65dd6ec35eb4b52ff556e1cabf411402 |
|
MD5 | 970006834384cdbbe990d2410df07d0c |
|
BLAKE2b-256 | 1d5b489dbe1885bedfb84a37e51b70b06294d8eceaabb6b1706ac7536ab01700 |
File details
Details for the file pytest_stats-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pytest_stats-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1022-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8d7e72ffd41b37a9342b58de1b163f0fe6ad969e6e84cb682c956e41f4f5805 |
|
MD5 | 6347692570227b72bf0babe954669953 |
|
BLAKE2b-256 | 481d25626b34421526579be1e733af073f7135e3fb51613265dfa59c22712fcf |