Skip to content

Commit

Permalink
adjust stateful spinner color to red once test fails
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 11, 2020
1 parent f5b37e4 commit 56a31ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion brownie/test/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def skip_coverage(self):
# implemented in pytest_collection_modifyitems
pass

@pytest.fixture(scope="session")
@pytest.fixture
def state_machine(self):
"""Yields a rule-based state machine factory method."""

Expand Down
21 changes: 20 additions & 1 deletion brownie/test/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,39 @@


class _BrownieStateMachine:

_failed = False

def __init__(self) -> None:
brownie.rpc.revert()
sf.RuleBasedStateMachine.__init__(self)

# pytest capturemanager plugin, added when accessed via the state_manager fixture
capman = getattr(self, "_capman", None)
if capman:
with capman.global_and_fixture_disabled():
sys.stdout.write(f"{color('yellow')}{marker[0]}\033[1D")
c = color("red" if self._failed else "yellow")
sys.stdout.write(f"{c}{marker[0]}\033[1D")
sys.stdout.flush()
marker.rotate(1)

if hasattr(self, "setup"):
self.setup() # type: ignore

def execute_step(self, step):
try:
super().execute_step(step)
except Exception:
type(self)._failed = True
raise

def check_invariants(self):
try:
super().check_invariants()
except Exception:
type(self)._failed = True
raise


def _member_filter(member: tuple) -> bool:
attr, fn = member
Expand Down

0 comments on commit 56a31ab

Please sign in to comment.