This release is a pre-release and may not be stable for production use.
Run With Coverage
Run a Python script with coverage tracking, allowing the user to specify the coverage data file - even in complex or non-standard environments.
- ✅ Python 2 & 3 compatible
- ✅ Windows & POSIX support
- ✅ Unicode-safe, including non-ASCII paths
- ✅ Safe
.coveragewriting, even when filenames contain spaces or non-UTF-8 characters - ✅ Temp file management compatible with SQLite's UTF-8-only file requirements
Fun Fact: The basic Unix implementation took 1 day. Windows compatibility took 14. You're welcome.
Installation
pip install run-with-coverage
After installation, run it as run_with_coverage.
Why This Exists
Most test runners (pytest, nose, etc.) and coverage tools (coverage.py) make assumptions:
- Filenames are UTF-8 or ASCII
- Paths don't contain spaces or non-English characters
- Python 3 is the only target platform
- subprocess is sufficient for launching scripts
These assumptions break in:
- Internationalized environments (e.g. Chinese, Japanese, Cyrillic filenames)
- Enterprise and legacy systems still running Python 2
- Windows, where environment variables use
mbcsand temp file encoding matters
Usage
run_with_coverage [-c <coverage_file>] [-v] [-L] -- <script_to_run> [args...]
-c: Coverage output file (default:.coverage)-v: Enable verbose logging-L: Measure library code--: Required delimiter to separate runner options from the script being tested
Example: Running on Windows with Non-ASCII Paths
This example runs a Python script in a Unicode path with arguments, saving the coverage file to a Unicode path as well.
Example script under test C:\Users\Administrator\Desktop\路径 有空格\名字 有空格.py:
# coding=utf-8
from __future__ import print_function
import sys
for i, arg in enumerate(sys.argv):
print('sys.argv[%d]=%s' % (i, arg))
Example command:
C:\Users\jifengwu2k\packages\run-with-coverage>run_with_coverage -c "..\..\路径 有空格\输出 文件.sqlite3" -v -- "..\..\路径 有空格\名字 有空 格.py" 参数1 "参数2 有空格"
Sample output:
2025-06-21 14:47:28,516 - DEBUG - Preparing to run script with coverage.
2025-06-21 14:47:28,516 - DEBUG - Script path: C:\Users\jifengwu2k\路径 有空格\名字 有空格.py
2025-06-21 14:47:28,516 - DEBUG - Arguments: [u'\u53c2\u65701', u'\u53c2\u65702 \u6709\u7a7a\u683c']
2025-06-21 14:47:28,516 - DEBUG - Coverage output path: C:\Users\jifengwu2k\路径 有空格\输出 文件.sqlite3
2025-06-21 14:47:28,517 - DEBUG - Temporary file for coverage created at: C:\Windows\Temp\tmphulafg
2025-06-21 14:47:28,517 - DEBUG - Launching process:
sys.argv[0]=C:\Users\jifengwu2k\路径 有空格\名字 有空格.py
sys.argv[1]=参数1
sys.argv[2]=参数2 有空格
2025-06-21 14:47:28,678 - INFO - Script exited with code: 0
2025-06-21 14:47:28,680 - DEBUG - Moving temp coverage file to final destination: C:\Users\jifengwu2k\路径 有空格\输出 文件.sqlite3
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Metadata
Release files for run-with-coverage 0.1.0a7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| run_with_coverage-0.1.0a7.tar.gz | 5.7 kB | Without provenance | Details for run_with_coverage-0.1.0a7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| run_with_coverage-0.1.0a7-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for run_with_coverage-0.1.0a7-py2.py3-none-any.whl |
Total release size: 12.0 kB
Release files / run_with_coverage-0.1.0a7.tar.gz
| Download URL | run_with_coverage-0.1.0a7.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
493e451aba51eca5e3080c752320ee6fc61a2360e310ac904e40d6d29a51debc
|
|
BLAKE2b-256 checksum How to use checksums |
8d728a6315212464fa6faa8fcd9c4fe985fb17804fc772c842480b9c50b64fe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / run_with_coverage-0.1.0a7-py2.py3-none-any.whl
| Download URL | run_with_coverage-0.1.0a7-py2.py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9c48b50a2813c369f80fd4fe71480522a9e5b89712185061b63c5b0f098d626e
|
|
BLAKE2b-256 checksum How to use checksums |
39a7e0b09e75b34908dbb0a42003b850bb041891139babc7ab9715b8efe89cb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Security for run-with-coverage 0.1.0a7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.