Skip to content

coverage is wrong when running with xdist's --boxed #9

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

Closed
diefans opened this issue May 26, 2014 · 20 comments
Closed

coverage is wrong when running with xdist's --boxed #9

diefans opened this issue May 26, 2014 · 20 comments
Labels

Comments

@diefans
Copy link

diefans commented May 26, 2014

I need to run my tests with xdist's --boxed feature.
there is a big difference in coverage compared to running unboxed:

  • unboxed: 93.48 %
  • boxed: 26.93 %

35 % of all modules are completely uncovered.
I also noticed, that despite that I run the tests with py.test tests/ --boxed -d -n 8 --random the uncovered modules are always the same.

When I run one single test module in boxed mode coverage complains that the module to cover was not imported:

py.test tests/unit/security/test_features.py --boxed -d -n 8 --cov bm.security
===================================================================================================== test session starts =====================================================================================================
platform linux2 -- Python 2.7.5 -- pytest-2.5.0
Tests are shuffled using seed number 358684703390.
plugins: random, bdd, cov, capturelog, ipdb, cache, pep8, greendots, xdist
gw0 [49] / gw1 [49] / gw2 [49] / gw3 [49] / gw4 [49] / gw5 [49] / gw6 [49] / gw7 [49]
scheduling tests via LoadScheduling
................................s..Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.......Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.Coverage.py warning: Module bm.security was never imported.
Coverage.py warning: No data was collected.
.
--------------------------------------------------------------------------------------- coverage: platform linux2, python 2.7.5-final-0 ---------------------------------------------------------------------------------------
Name    Stmts   Miss     Cover   Missing
----------------------------------------
============================================================================================ 48 passed, 1 skipped in 3.60 seconds =============================================================================================
@schlamar
Copy link
Contributor

Can you please test against latest master, there are various improvements/fixes not yet released.

@diefans
Copy link
Author

diefans commented May 26, 2014

Sorry, I get the same results...

@mattupstate
Copy link

I was experiencing a similar issue where running:

$ py.test --cov mymodule --cov-report=term-missing

was reporting correct coverage. Then when running through setuptools like:

$ python setup.py test

The coverage was incorrect. However, installing the latest from master branch has fixed my issue.

@schlamar
Copy link
Contributor

schlamar commented Jun 2, 2014

@diefans Confirmed: https://travis-ci.org/schlamar/pytest-cov/builds/26548730

@mattupstate That seems unrelated, but thanks for confirming that master solves a few issues.

@schlamar
Copy link
Contributor

schlamar commented Jun 2, 2014

@schlamar
Copy link
Contributor

schlamar commented Jun 5, 2014

@diefans I have a hacky but working solution by patching py.process.ForkedFunc. Not sure if I want to roll that out officially. But it should work if you add this to your conftest.py: fb100db

@schlamar
Copy link
Contributor

schlamar commented Jun 5, 2014

I have prepared a much nicer solution upstream:

@sontek
Copy link

sontek commented Jun 5, 2014

@schlamar Since this is upstream bug, does this mean you can release without the monkeypatching? Or are you going to wait for upstream anyways?

@schlamar
Copy link
Contributor

schlamar commented Jun 5, 2014

@sontek I'm going to wait for the decision on my pull request for py. If it is merged I can release because pytest-cov doesn't need any further changes.

@schlamar
Copy link
Contributor

@sontek 1.7.0 just released

@diefans this will be fixed as soon as a new py version is released, my pull request was merged

@schlamar
Copy link
Contributor

@diefans should be fixed, you just need to upgrade py to 1.4.21 and cov-core to 1.13.0.

@mocksoul
Copy link

@schlamar
Copy link
Contributor

Yes, I know. We are working something out. For now, you can pin py to 1.4.21.

@schlamar schlamar reopened this Jul 25, 2014
@mocksoul
Copy link

pytest 2.6.0 depends on py 1.4.22, so you require to downgrade them both =)

My 2 years old patch is still working:

  1. In session start record current PID
  2. Before test start compare current pid with session pid and if they are different -- make multiprocessing start
  3. Before teardown check is we used multiprocessing and stop it if needed

But I if you want things to make right you probably should ask xdist to provide box_start/box_stop hooks which you will be able to use.

@schlamar
Copy link
Contributor

@mocksoul Do you have some code? =)

@aconrad
Copy link

aconrad commented Aug 21, 2014

Do we have a fix for this?

@schlamar
Copy link
Contributor

@aconrad #15 should fix it, I might find some time at the weekend to have a look at it.

@schlamar schlamar added bug and removed enhancement labels Aug 22, 2014
@schlamar
Copy link
Contributor

fixed (again) in 1633bd3, will be released soon

dahlia added a commit to emcconville/wand that referenced this issue Aug 23, 2014
@aconrad
Copy link

aconrad commented Sep 4, 2014

Sweet! @schlamar can you ping this ticket when a new release is available? Thanks!

@mocksoul
Copy link

mocksoul commented Sep 4, 2014

As being said, it is fixed in pytest-cov-1.8.0, https://pypi.python.org/pypi/pytest-cov/1.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants