From fd9ff7280fa920c8f6efbe29c60968274da81650 Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 2 Jun 2020 12:44:18 +0400 Subject: [PATCH 1/2] fix: revert chain in failed hypothesis tests --- brownie/test/__init__.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/brownie/test/__init__.py b/brownie/test/__init__.py index 3b3d1001d..9d25ebad9 100644 --- a/brownie/test/__init__.py +++ b/brownie/test/__init__.py @@ -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 From 66c41a9811796f93460c80c3a2a705bdfaefe1ca Mon Sep 17 00:00:00 2001 From: Ben Hauser Date: Tue, 2 Jun 2020 14:13:40 +0400 Subject: [PATCH 2/2] fix: disable report_multiple_bugs for hypothesis tests The output with multiple bugs is very long and lacks code highlights. Diabling it is a quick fix to ensure the user gets a more readable output - long term it would be nice to find a way to format this output properly. --- brownie/_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/brownie/_config.py b/brownie/_config.py index 621c96522..558254880 100644 --- a/brownie/_config.py +++ b/brownie/_config.py @@ -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)