Skip to content

Non-deterministic test collection when using multiple fixtures #198

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
astrofrog opened this issue Aug 2, 2017 · 2 comments
Closed

Non-deterministic test collection when using multiple fixtures #198

astrofrog opened this issue Aug 2, 2017 · 2 comments

Comments

@astrofrog
Copy link

The following example causes non-deterministic failures when trying to run tests in parallel:

import pytest

@pytest.fixture(scope="module", params=['A', 'B'])
def fa(request):
    return request.param

@pytest.fixture(scope="module", params=['A', 'B'])
def fb(request):
    return request.param

def test_it(fa, fb):
    pass
$ pytest test.py  -n 4
================================== test session starts ==================================
platform darwin -- Python 3.6.2, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /Users/tom/tmp, inifile:
plugins: cov-2.3.1, mpl-0.8, xdist-1.18.2
gw0 [4] / gw1 [4] / gw2 [4] / gw3 [4]
scheduling tests via LoadScheduling
collecting 0 items / 1 errors
======================================== ERRORS =========================================
_________________________________ ERROR collecting gw3 __________________________________
Different tests were collected between gw1 and gw3. The difference is:
--- gw1

+++ gw3

@@ -1,4 +1,4 @@

 test.py::test_it[A-A]
+test.py::test_it[A-B]
+test.py::test_it[B-B]
 test.py::test_it[B-A]
-test.py::test_it[B-B]
-test.py::test_it[A-B]
================================ 1 error in 1.47 seconds ================================

Note that you need to try multiple times for the failure to appear in some cases. This is using Python 3.6.2 and pytest 3.1.3.

@nicoddemus
Copy link
Member

Can you try with pytest-3.2.0? I believe this has been fixed by pytest-dev/pytest#920

@astrofrog
Copy link
Author

It does seem to be fixed, thanks!

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

No branches or pull requests

2 participants