@@ -216,10 +216,6 @@ def test_any_method_after_close_throws_exception():
216
216
c .assignment ()
217
217
assert 'Consumer closed' == str (ex .value )
218
218
219
- with pytest .raises (RuntimeError ) as ex :
220
- c .store_offsets (offsets = [TopicPartition ("test" , 0 , 42 )])
221
- assert 'Consumer closed' == str (ex .value )
222
-
223
219
with pytest .raises (RuntimeError ) as ex :
224
220
c .commit ()
225
221
assert 'Consumer closed' == str (ex .value )
@@ -235,3 +231,23 @@ def test_any_method_after_close_throws_exception():
235
231
with pytest .raises (RuntimeError ) as ex :
236
232
lo , hi = c .get_watermark_offsets (TopicPartition ("test" , 0 ))
237
233
assert 'Consumer closed' == str (ex .value )
234
+
235
+
236
+ @pytest .mark .skipif (libversion ()[1 ] < 0x000b0000 ,
237
+ reason = "requires librdkafka >=0.11.0" )
238
+ def test_calling_store_offsets_after_close_throws_erro ():
239
+ """ calling store_offset after close should throw RuntimeError """
240
+
241
+ c = Consumer ({'group.id' : 'test' ,
242
+ 'enable.auto.commit' : True ,
243
+ 'enable.auto.offset.store' : False ,
244
+ 'socket.timeout.ms' : 50 ,
245
+ 'session.timeout.ms' : 100 })
246
+
247
+ c .subscribe (["test" ])
248
+ c .unsubscribe ()
249
+ c .close ()
250
+
251
+ with pytest .raises (RuntimeError ) as ex :
252
+ c .store_offsets (offsets = [TopicPartition ("test" , 0 , 42 )])
253
+ assert 'Consumer closed' == str (ex .value )
0 commit comments