Skip to content

Commit

Permalink
Merge pull request #2059 from Zalathar/fix-xdist
Browse files Browse the repository at this point in the history
Restore stable reprs across multiple processes in test_direct_strategies.py
  • Loading branch information
Zac-HD committed Jul 30, 2019
2 parents 7b4b8a1 + a8e0a42 commit 1bbdab8
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions hypothesis-python/tests/cover/test_direct_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@
import hypothesis.strategies as ds
from hypothesis import given, settings
from hypothesis.errors import InvalidArgument
from hypothesis.internal.reflection import nicerepr
from hypothesis.vendor.pretty import pretty
from tests.common.debug import minimal
from tests.common.utils import checks_deprecated_behaviour

# Use `pretty` instead of `repr` for building test names, so that set and dict
# parameters print consistently across multiple worker processes with different
# PYTHONHASHSEED values.


def fn_test(*fnkwargs):
fnkwargs = list(fnkwargs)
return pytest.mark.parametrize(
("fn", "args"),
fnkwargs,
ids=[
"%s(%s)" % (fn.__name__, ", ".join(map(nicerepr, args)))
"%s(%s)" % (fn.__name__, ", ".join(map(pretty, args)))
for fn, args in fnkwargs
],
)
Expand All @@ -50,14 +54,7 @@ def fn_ktest(*fnkwargs):
return pytest.mark.parametrize(
("fn", "kwargs"),
fnkwargs,
ids=[
"%s(%s)"
% (
fn.__name__,
", ".join(sorted("%s=%r" % (k, v) for k, v in kwargs.items())),
)
for fn, kwargs in fnkwargs
],
ids=["%s(**%s)" % (fn.__name__, pretty(kwargs)) for fn, kwargs in fnkwargs],
)


Expand Down

0 comments on commit 1bbdab8

Please sign in to comment.