@@ -22,20 +22,20 @@ class TestWeightedTransitionsBasic:
2222 def test_deterministic_with_seed (self , WeightedIdleSC ):
2323 sm = WeightedIdleSC ()
2424 sm .send ("idle" )
25- first_state = sm .current_state
25+ first_config = sm .configuration
2626
2727 sm .send ("finish" )
2828 sm .send ("idle" )
29- second_state = sm .current_state
29+ second_config = sm .configuration
3030
3131 # With seed=42, results are deterministic
3232 # Create a fresh instance to verify same seed produces same sequence
3333 sm2 = WeightedIdleSC ()
3434 sm2 .send ("idle" )
35- assert sm2 .current_state == first_state
35+ assert sm2 .configuration == first_config
3636 sm2 .send ("finish" )
3737 sm2 .send ("idle" )
38- assert sm2 .current_state == second_state
38+ assert sm2 .configuration == second_config
3939
4040 def test_statistical_distribution (self , WeightedIdleSC ):
4141 """Over many iterations, the distribution should approximate the weights."""
@@ -45,7 +45,7 @@ def test_statistical_distribution(self, WeightedIdleSC):
4545
4646 for _ in range (iterations ):
4747 sm .send ("idle" )
48- counts [sm .current_state .id ] += 1
48+ counts [next ( iter ( sm .configuration )) .id ] += 1
4949 sm .send ("finish" )
5050
5151 # With 70/20/10 weights, check roughly correct distribution (within 5%)
@@ -63,7 +63,7 @@ class SingleWeighted(StateChart):
6363
6464 sm = SingleWeighted ()
6565 sm .send ("go" )
66- assert sm .current_state == SingleWeighted .s2
66+ assert sm .configuration == { SingleWeighted .s2 }
6767
6868 def test_equal_weights (self ):
6969 class EqualWeights (StateChart ):
@@ -80,7 +80,7 @@ class EqualWeights(StateChart):
8080
8181 for _ in range (iterations ):
8282 sm .send ("go" )
83- counts [sm .current_state .id ] += 1
83+ counts [next ( iter ( sm .configuration )) .id ] += 1
8484 sm .send ("back" )
8585
8686 # Should be roughly 50/50 within 5%
@@ -102,7 +102,7 @@ class FloatWeights(StateChart):
102102
103103 for _ in range (iterations ):
104104 sm .send ("go" )
105- counts [sm .current_state .id ] += 1
105+ counts [next ( iter ( sm .configuration )) .id ] += 1
106106 sm .send ("back" )
107107
108108 assert abs (counts ["s2" ] / iterations - 0.70 ) < 0.05
@@ -119,7 +119,7 @@ class MixedWeights(StateChart):
119119
120120 sm = MixedWeights ()
121121 sm .send ("go" )
122- assert sm .current_state in ( MixedWeights .s2 , MixedWeights .s3 )
122+ assert sm .configuration & { MixedWeights .s2 , MixedWeights .s3 }
123123
124124
125125class TestWeightedTransitionsWithGuards :
@@ -147,7 +147,7 @@ def is_allowed(self):
147147 counts = Counter ()
148148 for _ in range (1000 ):
149149 sm .send ("go" )
150- counts [sm .current_state .id ] += 1
150+ counts [next ( iter ( sm .configuration )) .id ] += 1
151151 sm .send ("back" )
152152
153153 assert counts ["s2" ] > 0
@@ -175,7 +175,7 @@ def is_blocked(self):
175175
176176 # When not blocked, s2 can fire
177177 sm .send ("go" )
178- first_state = sm .current_state
178+ first_state = next ( iter ( sm .configuration ))
179179 sm .send ("back" )
180180
181181 # When blocked, s2 cond fails even if weight selects it
@@ -184,7 +184,7 @@ def is_blocked(self):
184184 for _ in range (100 ):
185185 try :
186186 sm .send ("go" )
187- results [sm .current_state .id ] += 1
187+ results [next ( iter ( sm .configuration )) .id ] += 1
188188 sm .send ("back" )
189189 except Exception :
190190 results ["failed" ] += 1
@@ -427,12 +427,12 @@ class MultiGroup(StateChart):
427427 sm = MultiGroup ()
428428
429429 sm .send ("go_a" )
430- state_a = sm .current_state
430+ state_a = next ( iter ( sm .configuration ))
431431 assert state_a in (MultiGroup .s2 , MultiGroup .s3 )
432432 sm .send ("back" )
433433
434434 sm .send ("go_b" )
435- state_b = sm .current_state
435+ state_b = next ( iter ( sm .configuration ))
436436 assert state_b in (MultiGroup .s4 , MultiGroup .s5 )
437437
438438
0 commit comments