Skip to content

Commit

Permalink
Run 'yapf -rpi setup.py hypothesis_trio'
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Jan 31, 2019
1 parent bc7cdfa commit 5d29758
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
23 changes: 16 additions & 7 deletions hypothesis_trio/stateful.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import trio
from trio.testing import trio_test


from hypothesis.stateful import (
# Needed for run_state_machine_as_test copy-paste
check_type,
Expand All @@ -21,10 +20,10 @@
MultipleResults,
)


# This is an ugly copy-paste since it's currently no possible to plug a special
# runner into run_state_machine_as_test


def run_state_machine_as_test(state_machine_factory, settings=None):
"""Run a state machine definition as a test, either silently doing nothing
or printing a minimal breaking program and raising an exception.
Expand All @@ -35,9 +34,13 @@ def run_state_machine_as_test(state_machine_factory, settings=None):
if settings is None:
try:
settings = state_machine_factory.TestCase.settings
check_type(Settings, settings, "state_machine_factory.TestCase.settings")
check_type(
Settings, settings, "state_machine_factory.TestCase.settings"
)
except AttributeError:
settings = Settings(deadline=None, suppress_health_check=HealthCheck.all())
settings = Settings(
deadline=None, suppress_health_check=HealthCheck.all()
)
check_type(Settings, settings, "settings")

@settings
Expand All @@ -49,11 +52,15 @@ def run_state_machine(factory, data):

n_steps = settings.stateful_step_count
should_continue = cu.many(
data.conjecture_data, min_size=1, max_size=n_steps, average_size=n_steps
data.conjecture_data,
min_size=1,
max_size=n_steps,
average_size=n_steps
)

print_steps = (
current_build_context().is_final or current_verbosity() >= Verbosity.debug
current_build_context().is_final
or current_verbosity() >= Verbosity.debug
)

# Plug a custom machinery
Expand Down Expand Up @@ -90,7 +97,8 @@ def run_state_machine(factory, data):
state_machine_factory, "_hypothesis_internal_use_seed", None
)
run_state_machine._hypothesis_internal_use_reproduce_failure = getattr(
state_machine_factory, "_hypothesis_internal_use_reproduce_failure", None
state_machine_factory, "_hypothesis_internal_use_reproduce_failure",
None
)

run_state_machine(state_machine_factory)
Expand Down Expand Up @@ -209,6 +217,7 @@ async def check_invariants(self):

# Monkey patching


def monkey_patch_hypothesis():
from hypothesis import stateful
stateful._old_run_state_machine_as_test = stateful.run_state_machine_as_test
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
author_email="[email protected]",
license="MIT -or- Apache License 2.0",
packages=find_packages(),
install_requires=[
"trio",
"hypothesis==4.4.3"
],
install_requires=["trio", "hypothesis==4.4.3"],
keywords=[
'async',
'hypothesis',
Expand Down

0 comments on commit 5d29758

Please sign in to comment.