Skip to content
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

sort by tests by some_hash_fn(f"{item.id!r}{randomly_seed}") rather than shuffle #210

Closed
graingert opened this issue Nov 11, 2019 · 1 comment · Fixed by #375
Closed

Comments

@graingert
Copy link
Member

graingert commented Nov 11, 2019

shuffle with the same seed isn't stable for item subsets and supersets:

import random


def shuffle(seed, v):
    v = list(v)
    random.Random(x=seed).shuffle(v)
    return v


assert (
    shuffle(1, "abcd") == ["d", "a", "c", "b"]
    and shuffle(1, "abc") == ["b", "c", "a"]
)

eg if you remove tests due to "--lf" or "--sw", or add/remove tests

@graingert graingert changed the title sort by tests by hash(item.id, random-seed) rather than shuffle sort by tests by hash(item.id, randomly-seed) rather than shuffle Nov 11, 2019
@graingert graingert changed the title sort by tests by hash(item.id, randomly-seed) rather than shuffle sort by tests by hash(f"{item.id!r}{randomly_seed}") rather than shuffle Nov 11, 2019
@graingert graingert changed the title sort by tests by hash(f"{item.id!r}{randomly_seed}") rather than shuffle sort by tests by some_hash_fn(f"{item.id!r}{randomly_seed}") rather than shuffle Nov 11, 2019
@tolomea
Copy link

tolomea commented Jan 26, 2021

👍

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

Successfully merging a pull request may close this issue.

2 participants