Issues

Issue #346 resolved

pytest-xdist and Python 3.3 is sort of broken

Donald Stufft avatarDonald Stufft created an issue

So running tests with pytest-xdist is somewhat broken when PYTHONHASHSEED is set to random (as it is in Python 3.3+ by default). It fails during the collection step trying to assert that two lists are the same. However it is apparently using data structures whose order is not defined so the lists have different ordering and the assertion fails. It can be worked around by setting PYTHONHASHSEED to something non random.

pytest-xdist should probably use sets instead of lists.

INTERNALERROR>   File "/Users/dstufft/.virtualenvs/pip33/lib/python3.3/site-packages/xdist/dsession.py", line 132, in init_distribute
INTERNALERROR>     assert collection == col
INTERNALERROR> AssertionError: assert ['tests/functional/test_bundle.py::test_create_bundle', 'tests/functional/test_bundle.py::test_cleanup_after_create_bu...t_completion.py::test_completion_for_unknown_shell', 'tests/functional/test_completion.py::test_completion_alone', ...] == ['tests/functional/test_bundle.py::test_create_bundle', 'tests/functional/test_bundle.py::test_cleanup_after_create_bu...t_completion.py::test_completion_for_unknown_shell', 'tests/functional/test_completion.py::test_completion_alone', ...]

Comments (9)

  1. holger krekel

    Not sure about how to best go about this. "collection" in general has order and the co-ordinating master node expects all slave nodes to generate the same collection of tests when in load-distribution mode (the default for "-n4"). The reported assertions has caused problems in the past already and it seems we need to think about a better technique. To address the issue at hand, however, we could think about using the same PYTHONHASHSEED in all slaves.

  2. holger krekel

    Hum, looking further into this, i am not sure what's going on here. PYTHONHASHSEED effects dictionaries and such, but pytest test ordering should not depend on dictionary or hash() order anywhere. So it would be interesting to see exactly what is not matching here.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.