@@ -226,7 +226,7 @@ def test_multiple_close_throw_exception():
226
226
227
227
with pytest .raises (RuntimeError ) as ex :
228
228
c .close ()
229
- assert 'Consumer already closed' == str ( ex . value )
229
+ assert ex . match ( 'Consumer already closed' )
230
230
231
231
232
232
def test_any_method_after_close_throws_exception ():
@@ -244,51 +244,51 @@ def test_any_method_after_close_throws_exception():
244
244
245
245
with pytest .raises (RuntimeError ) as ex :
246
246
c .subscribe (['test' ])
247
- assert 'Consumer closed' == str ( ex . value )
247
+ assert ex . match ( 'Consumer closed' )
248
248
249
249
with pytest .raises (RuntimeError ) as ex :
250
250
c .unsubscribe ()
251
- assert 'Consumer closed' == str ( ex . value )
251
+ assert ex . match ( 'Consumer closed' )
252
252
253
253
with pytest .raises (RuntimeError ) as ex :
254
254
c .poll ()
255
- assert 'Consumer closed' == str ( ex . value )
255
+ assert ex . match ( 'Consumer closed' )
256
256
257
257
with pytest .raises (RuntimeError ) as ex :
258
258
c .consume ()
259
- assert 'Consumer closed' == str ( ex . value )
259
+ assert ex . match ( 'Consumer closed' )
260
260
261
261
with pytest .raises (RuntimeError ) as ex :
262
262
c .assign ([TopicPartition ('test' , 0 )])
263
- assert 'Consumer closed' == str ( ex . value )
263
+ assert ex . match ( 'Consumer closed' )
264
264
265
265
with pytest .raises (RuntimeError ) as ex :
266
266
c .unassign ()
267
- assert 'Consumer closed' == str ( ex . value )
267
+ assert ex . match ( 'Consumer closed' )
268
268
269
269
with pytest .raises (RuntimeError ) as ex :
270
270
c .assignment ()
271
- assert 'Consumer closed' == str ( ex . value )
271
+ assert ex . match ( 'Consumer closed' )
272
272
273
273
with pytest .raises (RuntimeError ) as ex :
274
274
c .commit ()
275
- assert 'Consumer closed' == str ( ex . value )
275
+ assert ex . match ( 'Consumer closed' )
276
276
277
277
with pytest .raises (RuntimeError ) as ex :
278
278
c .committed ([TopicPartition ("test" , 0 )])
279
- assert 'Consumer closed' == str ( ex . value )
279
+ assert ex . match ( 'Consumer closed' )
280
280
281
281
with pytest .raises (RuntimeError ) as ex :
282
282
c .position ([TopicPartition ("test" , 0 )])
283
- assert 'Consumer closed' == str ( ex . value )
283
+ assert ex . match ( 'Consumer closed' )
284
284
285
285
with pytest .raises (RuntimeError ) as ex :
286
286
c .seek ([TopicPartition ("test" , 0 , 0 )])
287
- assert 'Consumer closed' == str ( ex . value )
287
+ assert ex . match ( 'Consumer closed' )
288
288
289
289
with pytest .raises (RuntimeError ) as ex :
290
290
lo , hi = c .get_watermark_offsets (TopicPartition ("test" , 0 ))
291
- assert 'Consumer closed' == str ( ex . value )
291
+ assert ex . match ( 'Consumer closed' )
292
292
293
293
294
294
@pytest .mark .skipif (libversion ()[1 ] < 0x000b0000 ,
@@ -308,16 +308,16 @@ def test_calling_store_offsets_after_close_throws_erro():
308
308
309
309
with pytest .raises (RuntimeError ) as ex :
310
310
c .store_offsets (offsets = [TopicPartition ("test" , 0 , 42 )])
311
- assert 'Consumer closed' == str ( ex . value )
311
+ assert ex . match ( 'Consumer closed' )
312
312
313
313
with pytest .raises (RuntimeError ) as ex :
314
314
c .offsets_for_times ([TopicPartition ("test" , 0 )])
315
- assert 'Consumer closed' == str ( ex . value )
315
+ assert ex . match ( 'Consumer closed' )
316
316
317
317
318
318
def test_consumer_withot_groupid ():
319
319
""" Consumer should raise exception if group.id is not set """
320
320
321
321
with pytest .raises (ValueError ) as ex :
322
322
Consumer ({'bootstrap.servers' : "mybroker:9092" })
323
- assert 'group.id must be set' in str ( ex )
323
+ assert ex . match ( 'group.id must be set' )
0 commit comments