{"action":"created","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/63","repository_url":"https://api.github.com/repos/pytest-dev/pytest-xdist","labels_url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/63/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/63/events","html_url":"https://github.com/pytest-dev/pytest-xdist/issues/63","id":158644022,"number":63,"title":"Collection fails with non-deterministic (e.g. random) parametrised tests","user":{"login":"allanlewis","id":194736,"avatar_url":"https://avatars.githubusercontent.com/u/194736?v=3","gravatar_id":"","url":"https://api.github.com/users/allanlewis","html_url":"https://github.com/allanlewis","followers_url":"https://api.github.com/users/allanlewis/followers","following_url":"https://api.github.com/users/allanlewis/following{/other_user}","gists_url":"https://api.github.com/users/allanlewis/gists{/gist_id}","starred_url":"https://api.github.com/users/allanlewis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allanlewis/subscriptions","organizations_url":"https://api.github.com/users/allanlewis/orgs","repos_url":"https://api.github.com/users/allanlewis/repos","events_url":"https://api.github.com/users/allanlewis/events{/privacy}","received_events_url":"https://api.github.com/users/allanlewis/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pytest-dev/pytest-xdist/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-06T10:13:18Z","updated_at":"2016-06-09T16:32:51Z","closed_at":null,"body":"I have a test that looks something like this:\r\n```py\r\n@pytest.mark.parametrise('sequence', [\r\n    [random.choice(my_list) for _ in range(n)]\r\n])\r\ndef test_foo():\r\n    pass  # Test implementation is irrelevant here\r\n```\r\nThis fails at collection time with an error like:\r\n```\r\ncollecting 0 items / 1 errors\r\n============================================================ ERRORS =============================================================\r\n_____________________________________________________ ERROR collecting gw1 ______________________________________________________\r\nDifferent tests were collected between gw0 and gw1. The difference is:\r\n--- gw0\r\n\r\n+++ gw1\r\n\r\n@@ -213,7 +213,7 @@\r\n\r\n-test_foo.py::test_foo[[a, b, c]]\r\n+test_foo.py::test_foo[[b, c, a]]\r\n```\r\n(The diff has some context and I've omitted some details specific to my environment, but hopefully it's clear.)\r\n\r\nSo it looks like `xdist` cares that each worker gets exactly the same list of tests _in the same order_: why is this? With a randomised test, I don't much care if I run with one random set of parameters or another: they're randomised on purpose. (I've also come across this issue where I generate parameters into an unordered collection like a `set`.)\r\n\r\nOther than using a fixed seed for the RNG (e.g. `random.seed(0)`), which defeats the purpose of the randomisation, is there a workaround for this? Or can something be done inside `xdist` to permit this sort of parametrised test?"},"comment":{"url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/comments/224951198","html_url":"https://github.com/pytest-dev/pytest-xdist/issues/63#issuecomment-224951198","issue_url":"https://api.github.com/repos/pytest-dev/pytest-xdist/issues/63","id":224951198,"user":{"login":"nicoddemus","id":1085180,"avatar_url":"https://avatars.githubusercontent.com/u/1085180?v=3","gravatar_id":"","url":"https://api.github.com/users/nicoddemus","html_url":"https://github.com/nicoddemus","followers_url":"https://api.github.com/users/nicoddemus/followers","following_url":"https://api.github.com/users/nicoddemus/following{/other_user}","gists_url":"https://api.github.com/users/nicoddemus/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoddemus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoddemus/subscriptions","organizations_url":"https://api.github.com/users/nicoddemus/orgs","repos_url":"https://api.github.com/users/nicoddemus/repos","events_url":"https://api.github.com/users/nicoddemus/events{/privacy}","received_events_url":"https://api.github.com/users/nicoddemus/received_events","type":"User","site_admin":false},"created_at":"2016-06-09T16:32:51Z","updated_at":"2016-06-09T16:32:51Z","body":"Oh I didn't know that, thanks for the clarification."}}
{"actor":{"display_login":"nicoddemus"}}