# pytest_pitch
`pytest_pitch` runs tests in an order such that coverage increases as fast as possible. Typically 99% of the total coverage is achieved in 10% of the test session time.

## use as pytest plugin for faster coverage increase
First create persistent time-coverage record via [pytest-donde](https://github.com/mikamove/pytest-donde)
```shell
python -m pytest [YOUR SESSION ARGS] --donde=/path/to/src
```
where `/path/to/src` is the code region to cover.
Then pass the record file to the plugin via
```shell
python -m pytest [YOUR SESSION ARGS] --pitch
```
If You change your test definitions or test selection `[YOUR SESSION ARGS]`
in step 2 without updating the record:
- tests which are unknown to step 1 (e.g. newly defined tests, less strict test selection)
will be put to the start of the execution order
- tests which are known to step 1 but missing in step 2 (e.g. removed tests, stricter test selection) will just be filtered out. Any selection mechanisms should not conflict with the reordering.
## use in your script
See [this script](https://github.com/mikamove/pytest-pitch/blob/main/scripts/benchmark_vs_project.py) as a demo which was used to create the image shown above.
## background
The plugin employs **Algorithm 1** from **p. 3** of
[S. Khuller, A. Moss, J. Naor, The budgeted maximum coverage problem, Inf. Process. Lett. 70, 1999](https://doi.org/10.1016/S0020-0190(99)00031-9).
## install
```shell
python -m pip install pytest_pitch
```
Raw data
{
"_id": null,
"home_page": "https://github.com/mikamove/pytest-pitch",
"name": "pytest-pitch",
"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/09/98/8b993bac3e0f12b8b7d10ae4378d56399a5f6b00119010577a1c800d72eb/pytest_pitch-1.0.5.tar.gz",
"platform": null,
"description": "# pytest_pitch\n\n`pytest_pitch` runs tests in an order such that coverage increases as fast as possible. Typically 99% of the total coverage is achieved in 10% of the test session time.\n\n\n\n## use as pytest plugin for faster coverage increase\n\nFirst create persistent time-coverage record via [pytest-donde](https://github.com/mikamove/pytest-donde)\n```shell\npython -m pytest [YOUR SESSION ARGS] --donde=/path/to/src\n```\nwhere `/path/to/src` is the code region to cover.\n\nThen pass the record file to the plugin via\n```shell\npython -m pytest [YOUR SESSION ARGS] --pitch\n```\n\nIf You change your test definitions or test selection `[YOUR SESSION ARGS]`\nin step 2 without updating the record:\n- tests which are unknown to step 1 (e.g. newly defined tests, less strict test selection)\n will be put to the start of the execution order\n- tests which are known to step 1 but missing in step 2 (e.g. removed tests, stricter test selection) will just be filtered out. Any selection mechanisms should not conflict with the reordering.\n\n## use in your script\n\nSee [this script](https://github.com/mikamove/pytest-pitch/blob/main/scripts/benchmark_vs_project.py) as a demo which was used to create the image shown above.\n\n## background\n\nThe plugin employs **Algorithm 1** from **p. 3** of\n[S. Khuller, A. Moss, J. Naor, The budgeted maximum coverage problem, Inf. Process. Lett. 70, 1999](https://doi.org/10.1016/S0020-0190(99)00031-9).\n\n## install\n\n```shell\npython -m pip install pytest_pitch\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "runs tests in an order such that coverage increases as fast as possible",
"version": "1.0.5",
"project_urls": {
"Homepage": "https://github.com/mikamove/pytest-pitch"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "555cf31dfcb414a9aa3b2f6d66b5371413f12125ea62d119ac2396a49b6c6ada",
"md5": "5fbdd77344919f594176a42b48d6e3be",
"sha256": "eaf6df306b02cb095b46e5b6719f8c28ffcbecef7d9cfc40ebbd569a7dd1e041"
},
"downloads": -1,
"filename": "pytest_pitch-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5fbdd77344919f594176a42b48d6e3be",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7749,
"upload_time": "2023-11-02T10:02:04",
"upload_time_iso_8601": "2023-11-02T10:02:04.851210Z",
"url": "https://files.pythonhosted.org/packages/55/5c/f31dfcb414a9aa3b2f6d66b5371413f12125ea62d119ac2396a49b6c6ada/pytest_pitch-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "09988b993bac3e0f12b8b7d10ae4378d56399a5f6b00119010577a1c800d72eb",
"md5": "0e048a3fbe4f08f383aa34439914f135",
"sha256": "9592b0d634d2ebd5a75b605d9191b03dd20aaf6f48d931f087a6e89765d8718c"
},
"downloads": -1,
"filename": "pytest_pitch-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "0e048a3fbe4f08f383aa34439914f135",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8113,
"upload_time": "2023-11-02T10:02:05",
"upload_time_iso_8601": "2023-11-02T10:02:05.960054Z",
"url": "https://files.pythonhosted.org/packages/09/98/8b993bac3e0f12b8b7d10ae4378d56399a5f6b00119010577a1c800d72eb/pytest_pitch-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-02 10:02:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mikamove",
"github_project": "pytest-pitch",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pytest-pitch"
}