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():
10
10
""" Basic API tests, these wont really do anything since there is no
11
11
broker configured. """
12
12
13
- try :
13
+ with pytest . raises ( TypeError ) as ex :
14
14
kc = Consumer ()
15
- except TypeError as e :
16
- assert str (e ) == "expected configuration dict"
15
+ assert ex .match ('expected configuration dict' )
17
16
18
17
def dummy_commit_cb (err , partitions ):
19
18
pass
Original file line number Diff line number Diff line change @@ -14,10 +14,9 @@ def test_basic_api():
14
14
""" Basic API tests, these wont really do anything since there is no
15
15
broker configured. """
16
16
17
- try :
17
+ with pytest . raises ( TypeError ) as ex :
18
18
p = Producer ()
19
- except TypeError as e :
20
- assert str (e ) == "expected configuration dict"
19
+ assert ex .match ('expected configuration dict' )
21
20
22
21
p = Producer ({'socket.timeout.ms' : 10 ,
23
22
'error_cb' : error_cb ,
@@ -136,10 +135,8 @@ def produce_hi(self):
136
135
assert type (sp ) == SubProducer
137
136
138
137
# Invalid config should fail
139
- try :
138
+ with pytest . raises ( KafkaException ) :
140
139
sp = SubProducer ({'should.fail' : False }, 'mytopic' )
141
- except KafkaException :
142
- pass
143
140
144
141
sp = SubProducer ({'log.thread.name' : True }, 'mytopic' )
145
142
sp .produce ('someother' , value = 'not hello' )
You can’t perform that action at this time.
0 commit comments