Skip to content

py.test not running any tests when using -n (xdist) #669

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
pytestbot opened this issue Jan 29, 2015 · 7 comments
Closed

py.test not running any tests when using -n (xdist) #669

pytestbot opened this issue Jan 29, 2015 · 7 comments
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: BitBucket: vmalloc, GitHub: vmalloc


When I run py.test without any arguments all my tests are running as expected:

$ py.test tests
========================================================= test session starts =========================================================
platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.6.4
plugins: capturelog, xdist
collected 438 items
....... (omitted)

=============================================== 435 passed, 3 skipped in 33.90 seconds ================================================

However, when I pass -n 4, nothing gets actually run:

$ py.test -n 4 
========================================================= test session starts =========================================================
platform darwin -- Python 2.7.9 -- py-1.4.26 -- pytest-2.6.4
plugins: capturelog, xdist
gw0 [439] / gw1 [439] / gw2 [439] / gw3 [439]
scheduling tests via LoadScheduling

==========================================================  in 3.03 seconds ===========================================================

@pytestbot
Copy link
Contributor Author

Original comment by BitBucket: vmalloc, GitHub: vmalloc:


Managed to pin the problem on a specific use case: it happens when parameters are different between workers in pytest.mark.parametrize. For instance, the following simple test will reproduce it:

#!python

import time

import pytest

@pytest.mark.parametrize('param', [time.time(), 1, 2, 3])
def test_something(param):
    pass

It would be helpful to at least get a clear error message explaining why things aren't running...

@pytestbot
Copy link
Contributor Author

Original comment by Rok Garbas (BitBucket: garbas, GitHub: garbas):


i also stumble upon this problem. (pytest-2.6.2, pytest-xdist-1.11)
somebody has any idea how to go about solving this? any pointers would be welcome.

@pytestbot
Copy link
Contributor Author

Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):


AFAIK when using xdist the tests collected on all hosts must have exactly the same test IDs. This means you can not have different parameters depending on the host.

You might be able to work around this in the above example by explicitly giving parameter IDs (which are used to create the test IDs): @pytest.mark.parametrize('param', params=[time.time(), 1, 2, 3], ids=['time', '1', '2', '3']).

@pytestbot
Copy link
Contributor Author

Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Actually, I believe this is a duplicate of issue #594.

@pytestbot
Copy link
Contributor Author

Original comment by Rok Garbas (BitBucket: garbas, GitHub: garbas):


same error is also present in pytest-2.7.0

@pytestbot pytestbot added the type: bug problem that needs to be addressed label Jun 15, 2015
@The-Compiler
Copy link
Member

When I run this with an up-to-date pytest and pytest-xdist, I get an error message instead:

================================== ERRORS ===================================
___________________________ ERROR collecting gw0 ____________________________
Different tests were collected between gw2 and gw0. The difference is:
--- gw2

+++ gw0

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

-foo.py::test_something[1436343943.2776034]
+foo.py::test_something[1436343943.234645]
 foo.py::test_something[1]
 foo.py::test_something[2]
 foo.py::test_something[3]
___________________________ ERROR collecting gw1 ____________________________
Different tests were collected between gw2 and gw1. The difference is:
--- gw2

+++ gw1

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

-foo.py::test_something[1436343943.2776034]
+foo.py::test_something[1436343943.2553692]
 foo.py::test_something[1]
 foo.py::test_something[2]
 foo.py::test_something[3]
___________________________ ERROR collecting gw3 ____________________________
Different tests were collected between gw2 and gw3. The difference is:
--- gw2

+++ gw3

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

-foo.py::test_something[1436343943.2776034]
+foo.py::test_something[1436343943.3050516]
 foo.py::test_something[1]
 foo.py::test_something[2]
 foo.py::test_something[3]

So can this be closed, @garbas?

@RonnyPfannschmidt
Copy link
Member

Closing as duplicate of #920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: parametrize related to @pytest.mark.parametrize type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants