File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def __init__(
7575 allow_event_without_transition : bool = False ,
7676 listeners : "List[object] | None" = None ,
7777 ):
78- self .model = model if model else Model ()
78+ self .model = model if model is not None else Model ()
7979 self .state_field = state_field
8080 self .start_value = start_value
8181 self .allow_event_without_transition = allow_event_without_transition
Original file line number Diff line number Diff line change @@ -488,3 +488,18 @@ class TrapStateMachine(StateMachine):
488488 start = started .to (producing )
489489 close = started .to (closed )
490490 add_job = producing .to .itself (internal = True )
491+
492+
493+ def test_model_with_custom_bool_is_not_replaced (campaign_machine ):
494+ class FalseyModel (MyModel ):
495+ def __bool__ (self ):
496+ return False
497+
498+ model = FalseyModel ()
499+ machine = campaign_machine (model )
500+
501+ assert machine .model is model
502+ assert model .state == "draft"
503+
504+ machine .produce ()
505+ assert model .state == "producing"
You can’t perform that action at this time.
0 commit comments