Skip to content

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

Description

@pytestbot

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 ===========================================================

Activity

  1. pytestbot commented on Feb 17, 2015

    @pytestbot
    ContributorAuthor

    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...

  2. pytestbot commented on Apr 30, 2015

    @pytestbot
    ContributorAuthor

    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.

  3. pytestbot commented on Apr 30, 2015

    @pytestbot
    ContributorAuthor

    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']).

  4. pytestbot commented on Apr 30, 2015

    @pytestbot
    ContributorAuthor

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


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

  5. pytestbot commented on Apr 30, 2015

    @pytestbot
    ContributorAuthor

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


    same error is also present in pytest-2.7.0

  6. The-Compiler commented on Jul 8, 2015

    @The-Compiler
    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?

  7. RonnyPfannschmidt commented on Jan 1, 2016

    @RonnyPfannschmidt
    Member

    Closing as duplicate of #920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: parametrizerelated to @pytest.mark.parametrizetype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions