Closed taranlu-houzz closed 3 years ago
I think that this issue seems like it might be related: #655
So, I found the solution to my issue: Adding the path to the subdir in the package that contains the stand-alone scripts to the source
list under tool.coverage.run
in my pyproject.toml
got things to work.
This was not immediately obvious as an issue, since coverage
was detecting the files, it just seems that it was not collecting data on them. Initially, in order to get coverage
to notice the subdir, I added __init__.py
as needed along the path (Python 3 should not need them). After adding the path to the subdir to my pyproject.toml
I was able to delete the extraneous __init__.py
files and coverage still reported on everything as expected.
Describe the bug Hello, I have a fairly unique problem: I have a new tool package that I am writing in Python 3. Within this package, there are some stand-alone scripts written in Python 2 (they use the
mayapy
utility script to invoke the Python interpreter in a valid environment for Autodesk Maya to run headless). In order to get coverage for these scripts, I have tried to follow the information on https://coverage.readthedocs.io/en/coverage-5.5/subprocess.html, but it does not seem to work for me. In order to get thesitecustomize.py
to load in the subprocess, I pass a modified environment to the subprocess command that looks like this:I am doing this for the following reasons:
coverage
package that has been installed into the virtualenv.sitecustomize.py
at the root of my project structure (thus, the need forpyproject_file_path().parent
).I have
coverage
configured via thepyproject.toml
:And this is my
sitecustomize.py
:I have tested running the subprocess with just invoking the interpreter via
mayapy
, and it works and gives the expected output from mysitecustomize.py
. However, when I try to run the actual scripts and then combine them, they always show 0% coverage for the files.Other information about my setup:
ward
to run tests: https://github.com/darrenburns/ward.To Reproduce How can we reproduce the problem? Please be specific. Don't just link to a failing CI job. Answer the questions below:
Expected behavior I would expect the coverage to be logged for the code run via the subprocesses.