File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
someA = ('a' 'a') -> state('a')
10
10
someB = ('b' 'b') -> state('b')
11
+ someC = ('c' 'c') -> state('c')
11
12
12
13
initial = someA
13
14
@@ -121,6 +122,18 @@ def test_ruleSwitchingViaState(self):
121
122
self .protocol .dataReceived ('abb' )
122
123
self .assertEqual (self .protocol .state .calls , ['a' , 'a' , 'b' ])
123
124
125
+ def test_ruleSwitchingViaStateGetsOverridden (self ):
126
+ """Returning a new rule takes priority over calling setNextRule."""
127
+ self .protocol .makeConnection (None )
128
+ self .protocol .dataReceived ('aa' )
129
+ self .assertEqual (self .protocol .state .calls , ['a' ])
130
+ self .protocol .dataReceived ('a' )
131
+ self .assertEqual (self .protocol .state .calls , ['a' ])
132
+ self .protocol .state .parser .setNextRule ('someB' )
133
+ self .protocol .state .returnMap ['a' ] = 'someC'
134
+ self .protocol .dataReceived ('acc' )
135
+ self .assertEqual (self .protocol .state .calls , ['a' , 'a' , 'c' ])
136
+
124
137
def test_connectionLoss (self ):
125
138
"""The reason for connection loss is forwarded to the state."""
126
139
self .protocol .makeConnection (None )
You can’t perform that action at this time.
0 commit comments