automating the subprocess measurement setup
See original GitHub issueOriginally reported by Tibor (Bitbucket: tibor_arpas, GitHub: Unknown)
Subprocesses in test suits are a common occurence. coverage.py has an execellent way to measure their coverage but the set-up instructions are quite scary: http://nedbatchelder.com/code/coverage/subprocess.html
Also in the time of tox, continuous integration, virtualizations and containerizations, the manual process is quite beside the point.
What could we do to completely automate the described process?
There is an article by Ned http://nedbatchelder.com/blog/201001/running_code_at_python_startup.html
and a suggestion from @geoffbache
#!python
# sitecustomize.py
import os, sys
currDir = os.path.dirname(__file__)
sys.path.remove(currDir)
del sys.modules["sitecustomize"]
try:
import sitecustomize
finally:
sys.path.insert(0, currDir)
That script fails on my machine (MacOS, Python 2.7) with
#!stacktrace
Traceback (most recent call last):
File "/Users/tibor/.virtualenvs/tmon/bin/../lib/python2.7/site.py", line 703, in <module>
main()
File "/Users/tibor/.virtualenvs/tmon/bin/../lib/python2.7/site.py", line 694, in main
execsitecustomize()
File "/Users/tibor/.virtualenvs/tmon/bin/../lib/python2.7/site.py", line 548, in execsitecustomize
import sitecustomize
File "/Users/tibor/tmonworkspace/testmon/sitecustomize.py", line 8, in <module>
sys.path.insert(0, currDir)
AttributeError: 'NoneType' object has no attribute 'path'
But I would hope that it’s the best approach.
Issue Analytics
- State:
- Created 8 years ago
- Comments:28 (12 by maintainers)
Top Results From Across the Web
The subprocess Module: Wrapping Programs With Python
In this tutorial, you'll learn how to leverage other apps and programs that aren't Python, wrapping them or launching them from your Python ......
Read more >Automation of a Quality Measurement System for Wireless ...
The installation of the Python will be covered in section three and section four concentrates on the implementation of the automated quality measurement...
Read more >Using subprocess to automate repeated executions of ...
1 Answer 1 ... Repeatedly reading and rewriting the input file is clumsy and inefficient, and anyway, you can't write to it when...
Read more >Measurement Automation using Python - Armms
measurement automation using the GPIB interface common on many instruments. ... The basic setup for the instrument and controller is shown in Figure...
Read more >Automation Guide for CMT VNAs
Because of this, if you want to automate the entire measurement process without using the VNA software's user interface, you must ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@glyph I think you can achieve your coverage groups by setting
COVERAGE_FILE
to.../coverage.groupname
and user parallel mode.What I just did in Klein’s Tox config is to set
COVERAGE_FILE={toxworkdir}/coverage.{envname}
, which (with parallel mode turned on) generate will generate a bunch of{toxworkdir}/coverage.{envname}.XXXX
files, that I combine after the test run. I can then setCOVERAGE_FILE={toxworkdir}/coverage
later to get a combined coverage file for all test runs.Original comment by Buck Evan (Bitbucket: bukzor, GitHub: bukzor)
The cov-core solution doesn’t uninstall whatsoever. In fact it causes the whole virtualenv to explode (ImportError) if you uninstall it.
The coverage-pth solution is better, but doesn’t handle
setup.py develop
akapip install -e
.The solution found in python-hunter handles all those cases, in addition to supporting easy-install. https://github.com/ionelmc/python-hunter/blob/master/setup.py
We’ve recently adapted this into a package that fills the same problem space as coverage-pth, but is more reliable.
IMO this should be a default feature of coveragepy. While it will add one if-statement to all subsequent python startup time, that seems like a near-zero cost to me, and the additional use-cases supported are sizeable.