
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
pytest-stats
Advanced tools
This library is collecting metadata about your test executions, and enables you to send it to a datastore of your liking.
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.
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:
ResultsReporter class)pytest_stats_register_reporters.@pytest.hookimpl()
def pytest_stats_register_reporters(reporters:'ReportersRegistry'):
reporters.register(MyReporter())
Most data is collected by hooking the following pytest-provided hooks:
pytest_sessionstartpytest_sessionfinishpytest_runtest_protocolpytest_runtest_makereportpytest_exception_interactpytest_stats_register_reporters: used to register a new reporter. More than one reporter can be registered at the same hook. pytest_configurepytest_stats_env_data: Enables adding custom environment information to the session data. pytest_sessionstartget_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 call get_test_item_data(item=request.node).foo="bar"FAQs
Collects tests metadata for future analysis, easy to extend for any data store
We found that pytest-stats demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.