Skip to content

Commit

Permalink
hypothesis/stateful.py:391
Browse files Browse the repository at this point in the history
  • Loading branch information
jobh committed Jun 25, 2024
1 parent 49f64cd commit fe60560
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def _add_result_to_targets(self, targets, result):
for target in targets:
name = self._new_name(target)

def printer(obj, p, cycle, name=name): # pragma: no cover # FIXME
def printer(obj, p, cycle, name=name):
return p.text(name)

self.__printer.singleton_pprinters.setdefault(id(result), printer)
Expand Down
18 changes: 18 additions & 0 deletions hypothesis-python/tests/cover/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ def test_flaky_draw_less_raises_flaky():
FlakyDrawLessMachine.TestCase().runTest()


def test_result_is_added_to_target():
class TargetStateMachine(RuleBasedStateMachine):
nodes = Bundle("nodes")

@rule(target=nodes, source=lists(nodes))
def bunch(self, source):
assert len(source) == 0
return source

test_class = TargetStateMachine.TestCase
try:
test_class().runTest()
raise RuntimeError("Expected an assertion error")
except AssertionError as err:
notes = err.__notes__
assert "state.bunch(source=[nodes_0])" in notes


class FlakyStateMachine(RuleBasedStateMachine):
@rule()
def action(self):
Expand Down

0 comments on commit fe60560

Please sign in to comment.