File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -638,7 +638,7 @@ def is_currently_empty(self, data):
638638
639639 def flatmap (self , expand ):
640640 if self .draw_references :
641- return type ( self ) (
641+ return Bundle (
642642 self .name ,
643643 consume = self .__reference_strategy .consume ,
644644 draw_references = False ,
Original file line number Diff line number Diff line change @@ -1472,6 +1472,27 @@ def use_directly(self, bun):
14721472 run_state_machine_as_test (Machine )
14731473
14741474
1475+ def test_flatmap_can_consume_bundle ():
1476+ class Machine (RuleBasedStateMachine ):
1477+ strings = Bundle ("strings" )
1478+
1479+ @initialize (target = strings )
1480+ def set_initial (self ):
1481+ return "sample text"
1482+
1483+ @rule (
1484+ target = strings ,
1485+ character = consumes (strings ).flatmap (lambda text : st .sampled_from (text )),
1486+ )
1487+ def consume_flatmapped (self , character ):
1488+ assert isinstance (character , str )
1489+ assert len (character ) == 1
1490+ return character
1491+
1492+ Machine .TestCase .settings = Settings (stateful_step_count = 5 , max_examples = 10 )
1493+ run_state_machine_as_test (Machine )
1494+
1495+
14751496def test_use_bundle_within_other_strategies ():
14761497 class Class :
14771498 def __init__ (self , value ):
You can’t perform that action at this time.
0 commit comments