A Coverage.py plugin to measure code coverage of shell scripts from python.
Project description
Coverage.sh
A Coverage.py plugin to measure code coverage of shell (sh or bash) scripts executed from python.
Installation
pip install coverage-sh
Usage
In your pyproject.toml
, set
[tool.coverage.run]
plugins = ["coverage_sh"]
and run
coverage run main.py
coverage combine
coverage html
to measure coverage of all shell scripts executed via the subprocess module, e.g.:
subprocess.run(["bash", "test.sh"])
The resulting coverage is then displayed alongside the coverage of the python files:
Caveats
The plugin works by patching the subprocess.Popen
class to set the "ENV" and "BASH_ENV" environment variables before
execution to source a helper script which enables tracing. This approach comes with a few caveats:
- It will only cover shell scripts that are executed via the subprocess module.
- Only bash and sh are supported
- Depending on the shell scripts, their trace files may become very large.
License
Licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for coverage_sh-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba4b40c69e1fa33955d0a2260cf4adb3bfd81d0637a781f3f1b1b25586b07ba7 |
|
MD5 | 7ce37354b7f5ac1c57474f8b1e676664 |
|
BLAKE2b-256 | 09887032530060ef3b410eaef0105c0826eccfaf1247b99fc1ec2267cd74a8ca |