record pytest session characteristics per test item (coverage and duration) into a persistent file and use them in your own plugin or script.
Project description
pytest_donde
pytest_donde
records per-test-item coverage and duration into a persistent file and offers an API to access this data in your plugins or scripts.
details
create persistent record
python -m pytest --donde=/path/to/src
This creates a donde.json
file with the following information for every test item:
- run duration (sec),
- covered lines of code w.r.t.
/path/to/src
by wrapping pytest-cov
, evaluating its output, and putting this together with collected test item durations.
access record
from pytest_donde import Outcome
outcome = Outcome.from_file('donde.json')
A demo example (which is trivial, because it uses only durations, not coverage):
class PluginPreferFastest:
def __init__(self, path_input):
self.outcome = Outcome.from_file(path_input)
def pytest_collection_modifyitems(self, session, config, items):
def key(item):
try:
return self.outcome.nodeid_to_duration(item.nodeid)
except KeyError:
# test is unknown to the donde.json record,
# possibly it was skipped there or was added after the record was made
# we prefer it to run at the beginning
return 0.0
items[:] = sorted(items, key=key)
install
python -m pip install pytest-donde
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest_donde-1.0.0.tar.gz
(8.8 kB
view hashes)
Built Distribution
Close
Hashes for pytest_donde-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14e1d424e1a57dec7f42c5551dfd273b1ab544894f3a9be65ef76f2ec865ff7f |
|
MD5 | 00e5a029912f21802e7016850c422623 |
|
BLAKE2b-256 | 381ec4ff79ba80d9e0beb98ae73351cec2680e082f7dc1fcd306dff083ef6d87 |