-
-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest and multiprocessing: CoverageException: Can't combine line data with arc dat #512
Comments
Original comment by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin) Any update on this? I'm currently having to choose between coverage and running some tests. |
@samuelcolvin Sorry, I haven't started digging into this. It does sounds a lot like the fix I put in 4.2, so I will have to look at it soon. Have you tried it with the tip of coverage.py? |
Original comment by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin) Same error with
|
I tried running your scenario, and did not get the error you describe. The full output is here: https://gist.github.com/nedbat/a482ea69fa509de5e0a7c3da8f378e4b The test run ends with:
I'm not sure what caused my test failures, but I wouldn't think they are significant in this case. |
Original comment by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin) looks like you don't have redis installed. |
@samuelcolvin I'm willing to try reproducing this, but I need explicit instructions, or I'll wander in the redis-wilderness for a while. What should I do on my Mac to get things to pass? Do you think the test failures are preventing the coverage failure? |
Original comment by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin) Sorry about that, on ubuntu redis runs as a service so is always there. I've dusted off my mac and tried to run the code however brew seems to be broken so I can't install python3.5. As far as I know it should be as simple:
|
Original comment by Ionel Cristian Mărieș (Bitbucket: ionelmc, GitHub: ionelmc) I've taken a look at this as well, my opinion is that a combination of configuration, subprocess use and cwd changes cause the problem. That's why you get the data file saved without arcs (branch=False). There are thee ways to deal with this:
There is no bug in either coverage or pytest-cov here. Also, note that |
I've come to some different conclusions that Ionel did, though he was very helpful in getting me going with debugging with his aspectlib. The problem here is the Process spawned by test_repeat_worker_close. It doesn't find the same configuration file that the rest of the tests do. Specifying I think this is a combination of the direct use of Process, which perhaps coverage.py hasn't patched enough, and having settings in the implicitly-read setup.cfg file. One simple solution is to move your coverage.py settings into a .coveragerc file. If you do that, things work. |
Original comment by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin) Ned, thanks so much for the help. I've switched to using Perhaps a comment in the docs saying that using |
@ionelmc it isn't enough to tell coverage.py to use setup.cfg. It won't be read properly unless it is discovered implicitly. |
The sections are named differently ("[run]" vs "[coverage:run]"). If you specify setup.cfg as the file, coverage.py will try to read the "[run]" section and won't find it. It only looks for "[coverage:run]" when it is reading setup.cfg because it couldn't find .coveragerc. Of course, this behavior could change, but that's the way the code is now. |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) The following patch retries with the coverage: prefix if a non default file was specified and nothing was read from it. There could be a cleaner way to do the same and I'm willing to work on it if you think it is worth implementing. To be fully backward compatible it should only retry with the coverage: prefix in the case where a file was provided and nothing was read from it because it serves no useful purpose. Unless there is a valid use case for --rcfile=/dev/null ?
|
Original comment by Miguel Sánchez de León Peque (Bitbucket: Peque, GitHub: Peque) I think I may have hit this issue too. Builds used to pass without any problems, but when moving the configuration from |
Original comment by Miguel Sánchez de León Peque (Bitbucket: Peque, GitHub: Peque) @ionelmc Thanks. That helped and it currently finishes the report. However, the Have not figured out why. Here is the repo/branch: https://github.com/Peque/osbrain/tree/coverage |
My project uses a |
@joshfriend can you give us specific instructions to reproduce what you are seeing, even if it's cloning your full project? |
Feel free to re-open if you get more information. |
Thanks. Does this include the "dataop" setting, and is it the full log (other than "...snip...")? I've added another debug message to coverage master, if you could run it again with dataop. |
Yes, I updated to coverage @ cf712c6 and almost immediately had one failing test run. The log output looked identical to before, though so far I have only had one
Also, I'm not sure if this is expected, but when debug is printed to stderr instead of a file, an exception is thrown at the end:
|
Just ran into this bug and worked around it with Unfortunately, those subprocesses were not reading the toml file, and were generating data in arc instead of line (or vice-versa, I can't remember...), thus the error. I had to copy my config out of the Prior to the patch, there was some weirdness with collectors on Windows.Tests would always show this kind of noise:
but only on Windows. Go figure. Hope this detail helps track down the bug. |
I get this error when I use |
I do use |
My question is: does turning off |
The issue is not able to be replicated reliably in my projects, so unfortunately I could not tell you |
Yes, I use |
We also use pyproject.toml for our coverage configuration, and wanted to mention that I both encountered and was (seemingly) able to work around this issue by explicitly specifying |
I have been using explicit I have not changed anything about my coverage setup other than to update coverage.py as new versions come out periodically, and I rarely see this issue anymore. It used to happen quite frequently, but recently is so infrequent that I can't try anything to debug it, but it is also not annoying anymore so I stopped trying. |
Tried this and it didn't work -- is your project multiprocess as well? |
Hmm, our project itself doesn't use multiprocessing so I suppose the scenario is slightly different, but we do use pytest-xdist to distribute test cases across cores, which seems to be the cause of the error in our case. |
Specifying --cov-config=setup.cfg as an addopted parameter in my setup.cfg solved the issue for me. Thanks! Here are a few keywords on my setting so others might find this solution: |
I think I am running into a similar issue in my project. Traceback
If you want you can reproduce the error using my project (Docker required): git clone https://github.com/cblessing24/compenv
cd compenv
git checkout b0aafca39898bdd4487ae57869adc43c49b093fe
docker build -t cblessing24/compenv .
touch .env
docker compose run pytest_github Adding |
This change is a workaround for nedbat/coveragepy#512.
Thanks all. I'm going to close this issue because: 1) it seems to be about pytest-cov, not coverage.py, and 2) there's a fix, which is to explicitly name your coverage configuration file with |
This is needed to fix the coverage failures detailed at nedbat/coveragepy#512 We may instead need to have this listed somewhere else however, as if pytest can't pick up the pyproject.toml it can't read the line telling it to use it.
This is needed to fix the coverage failures detailed at nedbat/coveragepy#512 We may instead need to have this listed somewhere else however, as if pytest can't pick up the pyproject.toml it can't read the line telling it to use it.
This is needed to fix the coverage failures detailed at nedbat/coveragepy#512 We may instead need to have this listed somewhere else however, as if pytest can't pick up the pyproject.toml it can't read the line telling it to use it.
Do we still need the workaround of passing explicitly |
Originally reported by Samuel Colvin (Bitbucket: samuelcolvin, GitHub: samuelcolvin)
I'm getting
CoverageException: Can't combine line data with arc dat
when using coverage with the pytest-cov pytest extension. I think this is similar to #399, but that issue is closed.Example failure on travis: https://travis-ci.org/samuelcolvin/arq/builds/148541711
The test causing problems is using click's
CliRunner
, code here. The CLI command that's testing starts another process (usingmultiprocessing.Process
) to run the worker which is what's causing the problem, if you prevent the worker process being started the exception doesn't occur.I tried changing the
concurrency
mode but it made no difference.To reproduce: clone,
pip install -e . && pip install -r tests/requirements.txt
,py.test --cov=arq
.relevant bits of
pip freeze
:Let me know if you need anymore information.
The text was updated successfully, but these errors were encountered: