pytest-donde


Namepytest-donde JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/mikamove/pytest-donde
Summaryrecord pytest session characteristics per test item (coverage and duration) into a persistent file and use them in your own plugin or script.
upload_time2023-09-28 22:17:34
maintainerClemens Löbner
docs_urlNone
authorClemens Löbner
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```shell
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

```python
from pytest_donde import Outcome
outcome = Outcome.from_file('donde.json')
```

A demo example (which is trivial, because it uses only durations, not coverage):

```python

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

```shell
python -m pip install pytest-donde
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mikamove/pytest-donde",
    "name": "pytest-donde",
    "maintainer": "Clemens L\u00f6bner",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "mikamove@posteo.de",
    "keywords": "",
    "author": "Clemens L\u00f6bner",
    "author_email": "mikamove@posteo.de",
    "download_url": "https://files.pythonhosted.org/packages/f3/17/9c83c91d6f3782c01b85c4b2dc36a8846df6cbdb5cb802f1c42fbc3c46c9/pytest_donde-1.0.0.tar.gz",
    "platform": null,
    "description": "# pytest_donde\n\n`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.\n\n## details\n\n### create persistent record\n\n```shell\npython -m pytest --donde=/path/to/src\n```\n\nThis creates a `donde.json` file with the following information for every test item:\n- run duration (sec),\n- covered lines of code w.r.t. `/path/to/src`\n\nby wrapping `pytest-cov`, evaluating its output, and putting this together with collected test item durations.\n\n### access record\n\n```python\nfrom pytest_donde import Outcome\noutcome = Outcome.from_file('donde.json')\n```\n\nA demo example (which is trivial, because it uses only durations, not coverage):\n\n```python\n\nclass PluginPreferFastest:\n\n    def __init__(self, path_input):\n        self.outcome = Outcome.from_file(path_input)\n\n    def pytest_collection_modifyitems(self, session, config, items):\n\n        def key(item):\n            try:\n                return self.outcome.nodeid_to_duration(item.nodeid)\n            except KeyError:\n                # test is unknown to the donde.json record,\n                # possibly it was skipped there or was added after the record was made\n                # we prefer it to run at the beginning\n                return 0.0\n\n        items[:] = sorted(items, key=key)\n```\n\n## install\n\n```shell\npython -m pip install pytest-donde\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "record pytest session characteristics per test item (coverage and duration) into a persistent file and use them in your own plugin or script.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/mikamove/pytest-donde"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "381ec4ff79ba80d9e0beb98ae73351cec2680e082f7dc1fcd306dff083ef6d87",
                "md5": "00e5a029912f21802e7016850c422623",
                "sha256": "14e1d424e1a57dec7f42c5551dfd273b1ab544894f3a9be65ef76f2ec865ff7f"
            },
            "downloads": -1,
            "filename": "pytest_donde-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "00e5a029912f21802e7016850c422623",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7623,
            "upload_time": "2023-09-28T22:17:33",
            "upload_time_iso_8601": "2023-09-28T22:17:33.146489Z",
            "url": "https://files.pythonhosted.org/packages/38/1e/c4ff79ba80d9e0beb98ae73351cec2680e082f7dc1fcd306dff083ef6d87/pytest_donde-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3179c83c91d6f3782c01b85c4b2dc36a8846df6cbdb5cb802f1c42fbc3c46c9",
                "md5": "6413df1ee5286cba3ce033aa20c44f7c",
                "sha256": "bbab662556eb1091a191be39519e21e84430debc84029a605be7840d4e16c573"
            },
            "downloads": -1,
            "filename": "pytest_donde-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6413df1ee5286cba3ce033aa20c44f7c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8768,
            "upload_time": "2023-09-28T22:17:34",
            "upload_time_iso_8601": "2023-09-28T22:17:34.887097Z",
            "url": "https://files.pythonhosted.org/packages/f3/17/9c83c91d6f3782c01b85c4b2dc36a8846df6cbdb5cb802f1c42fbc3c46c9/pytest_donde-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-28 22:17:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mikamove",
    "github_project": "pytest-donde",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-donde"
}
        
Elapsed time: 0.14361s