File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,9 @@ def test_basic_api():
1010 """ Basic API tests, these wont really do anything since there is no
1111 broker configured. """
1212
13- try :
13+ with pytest . raises ( TypeError ) as ex :
1414 kc = Consumer ()
15- except TypeError as e :
16- assert str (e ) == "expected configuration dict"
15+ assert ex .match ('expected configuration dict' )
1716
1817 def dummy_commit_cb (err , partitions ):
1918 pass
Original file line number Diff line number Diff line change @@ -14,10 +14,9 @@ def test_basic_api():
1414 """ Basic API tests, these wont really do anything since there is no
1515 broker configured. """
1616
17- try :
17+ with pytest . raises ( TypeError ) as ex :
1818 p = Producer ()
19- except TypeError as e :
20- assert str (e ) == "expected configuration dict"
19+ assert ex .match ('expected configuration dict' )
2120
2221 p = Producer ({'socket.timeout.ms' : 10 ,
2322 'error_cb' : error_cb ,
@@ -136,10 +135,8 @@ def produce_hi(self):
136135 assert type (sp ) == SubProducer
137136
138137 # Invalid config should fail
139- try :
138+ with pytest . raises ( KafkaException ) :
140139 sp = SubProducer ({'should.fail' : False }, 'mytopic' )
141- except KafkaException :
142- pass
143140
144141 sp = SubProducer ({'log.thread.name' : True }, 'mytopic' )
145142 sp .produce ('someother' , value = 'not hello' )
You can’t perform that action at this time.
0 commit comments