@@ -121,13 +121,15 @@ def iter_content(self, *args, **kwargs):
121
121
122
122
123
123
@pytest .mark .parametrize (
124
- "random_split,resp_message_is_proto_plus,response_type " ,
125
- [(False , True , EchoResponse ), (False , False , httpbody_pb2 . HttpBody )],
124
+ "random_split,resp_message_is_proto_plus" ,
125
+ [(False , True ), (False , False )],
126
126
)
127
- def test_next_simple (random_split , resp_message_is_proto_plus , response_type ):
127
+ def test_next_simple (random_split , resp_message_is_proto_plus ):
128
128
if resp_message_is_proto_plus :
129
+ response_type = EchoResponse
129
130
responses = [EchoResponse (content = "hello world" ), EchoResponse (content = "yes" )]
130
131
else :
132
+ response_type = httpbody_pb2 .HttpBody
131
133
responses = [
132
134
httpbody_pb2 .HttpBody (content_type = "hello world" ),
133
135
httpbody_pb2 .HttpBody (content_type = "yes" ),
@@ -141,23 +143,25 @@ def test_next_simple(random_split, resp_message_is_proto_plus, response_type):
141
143
142
144
143
145
@pytest .mark .parametrize (
144
- "random_split,resp_message_is_proto_plus,response_type " ,
146
+ "random_split,resp_message_is_proto_plus" ,
145
147
[
146
- (True , True , Song ),
147
- (False , True , Song ),
148
- (True , False , http_pb2 . HttpRule ),
149
- (False , False , http_pb2 . HttpRule ),
148
+ (True , True ),
149
+ (False , True ),
150
+ (True , False ),
151
+ (False , False ),
150
152
],
151
153
)
152
- def test_next_nested (random_split , resp_message_is_proto_plus , response_type ):
154
+ def test_next_nested (random_split , resp_message_is_proto_plus ):
153
155
if resp_message_is_proto_plus :
156
+ response_type = Song
154
157
responses = [
155
158
Song (title = "some song" , composer = Composer (given_name = "some name" )),
156
159
Song (title = "another song" , date_added = datetime .datetime (2021 , 12 , 17 )),
157
160
]
158
161
else :
159
162
# Although `http_pb2.HttpRule`` is used in the response, any response message
160
163
# can be used which meets this criteria for the test of having a nested field.
164
+ response_type = http_pb2 .HttpRule
161
165
responses = [
162
166
http_pb2 .HttpRule (
163
167
selector = "some selector" ,
@@ -176,22 +180,24 @@ def test_next_nested(random_split, resp_message_is_proto_plus, response_type):
176
180
177
181
178
182
@pytest .mark .parametrize (
179
- "random_split,resp_message_is_proto_plus,response_type " ,
183
+ "random_split,resp_message_is_proto_plus" ,
180
184
[
181
- (True , True , Song ),
182
- (False , True , Song ),
183
- (True , False , http_pb2 . HttpRule ),
184
- (False , False , http_pb2 . HttpRule ),
185
+ (True , True ),
186
+ (False , True ),
187
+ (True , False ),
188
+ (False , False ),
185
189
],
186
190
)
187
- def test_next_stress (random_split , resp_message_is_proto_plus , response_type ):
191
+ def test_next_stress (random_split , resp_message_is_proto_plus ):
188
192
n = 50
189
193
if resp_message_is_proto_plus :
194
+ response_type = Song
190
195
responses = [
191
196
Song (title = "title_%d" % i , composer = Composer (given_name = "name_%d" % i ))
192
197
for i in range (n )
193
198
]
194
199
else :
200
+ response_type = http_pb2 .HttpRule
195
201
responses = [
196
202
http_pb2 .HttpRule (
197
203
selector = "selector_%d" % i ,
@@ -207,18 +213,17 @@ def test_next_stress(random_split, resp_message_is_proto_plus, response_type):
207
213
208
214
209
215
@pytest .mark .parametrize (
210
- "random_split,resp_message_is_proto_plus,response_type " ,
216
+ "random_split,resp_message_is_proto_plus" ,
211
217
[
212
- (True , True , Song ),
213
- (False , True , Song ),
214
- (True , False , http_pb2 . Http ),
215
- (False , False , http_pb2 . Http ),
218
+ (True , True ),
219
+ (False , True ),
220
+ (True , False ),
221
+ (False , False ),
216
222
],
217
223
)
218
- def test_next_escaped_characters_in_string (
219
- random_split , resp_message_is_proto_plus , response_type
220
- ):
224
+ def test_next_escaped_characters_in_string (random_split , resp_message_is_proto_plus ):
221
225
if resp_message_is_proto_plus :
226
+ response_type = Song
222
227
composer_with_relateds = Composer ()
223
228
relateds = ["Artist A" , "Artist B" ]
224
229
composer_with_relateds .relateds = relateds
@@ -234,6 +239,7 @@ def test_next_escaped_characters_in_string(
234
239
Song (title = '\\ {"key": ["value",]}\\ ' , composer = composer_with_relateds ),
235
240
]
236
241
else :
242
+ response_type = http_pb2 .Http
237
243
responses = [
238
244
http_pb2 .Http (
239
245
rules = [
@@ -318,3 +324,5 @@ def test_next_html(response_type):
318
324
with pytest .raises (ValueError ):
319
325
next (itr )
320
326
mock_method .assert_called_once ()
327
+
328
+
0 commit comments