Skip to main content

pytest_donde

pytest_donde dumps per-test-item coverage and duration into a persistent record file and offers an API to access this record in your plugins or scripts.

details

create persistent record

python -m pytest --donde=/path/to/src

This creates a donde.json record 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 Record
record = Record.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.record = Record.from_file(path_input)

    def pytest_collection_modifyitems(self, items):

        def key(item):
            try:
                return self.record.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

Release files for pytest-donde 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-donde 1.1.0
File Size Uploaded
pytest_donde-1.1.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-donde 1.1.0
File Interpreter ABI Platform
pytest_donde-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / pytest_donde-1.1.0.tar.gz

Download URL pytest_donde-1.1.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9722f899a657da9cb953f7bbb0b780933ddaa3ff93ea751af75f616714cc9af7
BLAKE2b-256 checksum
How to use checksums
4f46215e049542be2e133ade1d7e965a57b1491ca342b593a51aa7eab360d9c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release files / pytest_donde-1.1.0-py3-none-any.whl

Download URL pytest_donde-1.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cc22865959ba5530b8d6b9782ff50385542e8122f083ffe75a6c02e075c1792
BLAKE2b-256 checksum
How to use checksums
bf47ab419d66c4ff57f1435dba06581e79b9049007897e337e6572c2cbcabd3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page