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

Hypothesis fixes #591

Merged
merged 2 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions brownie/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def _modify_hypothesis_settings(settings, name, parent):
name,
parent=hp_settings.get_profile(parent),
database=DirectoryBasedExampleDatabase(_get_data_folder().joinpath("hypothesis")),
report_multiple_bugs=False,
**settings,
)
hp_settings.load_profile(name)
Expand Down
14 changes: 12 additions & 2 deletions brownie/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ def given(*given_args, **given_kwargs):
"""

def outer_wrapper(test):
first_run = True

def isolation_wrapper(*args, **kwargs):
network.rpc.snapshot()
nonlocal first_run
if first_run:
# prior to the first test run, take a snapshot to ensure
# consistent chain state for each run
network.rpc.snapshot()
first_run = False
else:
# revert at the start of subsequent tests runs so the chain is
# not reverted prior to launching the interactive debugger
network.rpc.revert()
test(*args, **kwargs)
network.rpc.revert()

# hypothesis.given must wrap the target test to correctly
# impersonate the call signature for pytest
Expand Down