Skip to content

Commit 70621df

Browse files
committed
formatting
Signed-off-by: Gabriele Santomaggio <[email protected]>
1 parent 4023804 commit 70621df

File tree

1 file changed

+43
-56
lines changed

1 file changed

+43
-56
lines changed

tests/test_streams.py

Lines changed: 43 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ def test_stream_read_from_last_default(
5454
# ack to terminate the consumer
5555
except ConsumerTestException:
5656
pass
57-
58-
consumer.close()
59-
60-
management.delete_queue(stream_name)
57+
finally:
58+
consumer.close()
59+
management.delete_queue(stream_name)
6160

6261

6362
def test_stream_read_from_last(
@@ -91,10 +90,9 @@ def test_stream_read_from_last(
9190
# ack to terminate the consumer
9291
except ConsumerTestException:
9392
pass
94-
95-
consumer.close()
96-
97-
management.delete_queue(stream_name)
93+
finally:
94+
consumer.close()
95+
management.delete_queue(stream_name)
9896

9997

10098
def test_stream_read_from_offset_zero(
@@ -128,10 +126,9 @@ def test_stream_read_from_offset_zero(
128126
# ack to terminate the consumer
129127
except ConsumerTestException:
130128
pass
131-
132-
consumer.close()
133-
134-
management.delete_queue(stream_name)
129+
finally:
130+
consumer.close()
131+
management.delete_queue(stream_name)
135132

136133

137134
def test_stream_read_from_offset_first(
@@ -165,10 +162,9 @@ def test_stream_read_from_offset_first(
165162
# ack to terminate the consumer
166163
except ConsumerTestException:
167164
pass
168-
169-
consumer.close()
170-
171-
management.delete_queue(stream_name)
165+
finally:
166+
consumer.close()
167+
management.delete_queue(stream_name)
172168

173169

174170
def test_stream_read_from_offset_ten(
@@ -203,10 +199,9 @@ def test_stream_read_from_offset_ten(
203199
# this will finish after 10 messages read
204200
except ConsumerTestException:
205201
pass
206-
207-
consumer.close()
208-
209-
management.delete_queue(stream_name)
202+
finally:
203+
consumer.close()
204+
management.delete_queue(stream_name)
210205

211206

212207
def test_stream_filtering(connection: Connection, environment: Environment) -> None:
@@ -240,10 +235,9 @@ def test_stream_filtering(connection: Connection, environment: Environment) -> N
240235
# ack to terminate the consumer
241236
except ConsumerTestException:
242237
pass
243-
244-
consumer.close()
245-
246-
management.delete_queue(stream_name)
238+
finally:
239+
consumer.close()
240+
management.delete_queue(stream_name)
247241

248242

249243
def test_stream_filtering_mixed(
@@ -281,10 +275,9 @@ def test_stream_filtering_mixed(
281275
# ack to terminate the consumer
282276
except ConsumerTestException:
283277
pass
284-
285-
consumer.close()
286-
287-
management.delete_queue(stream_name)
278+
finally:
279+
consumer.close()
280+
management.delete_queue(stream_name)
288281

289282

290283
def test_stream_filtering_not_present(
@@ -362,10 +355,9 @@ def test_stream_match_unfiltered(
362355
# ack to terminate the consumer
363356
except ConsumerTestException:
364357
pass
365-
366-
consumer.close()
367-
368-
management.delete_queue(stream_name)
358+
finally:
359+
consumer.close()
360+
management.delete_queue(stream_name)
369361

370362

371363
def test_stream_reconnection(
@@ -403,10 +395,9 @@ def test_stream_reconnection(
403395
# ack to terminate the consumer
404396
except ConsumerTestException:
405397
pass
406-
407-
consumer.close()
408-
409-
management.delete_queue(stream_name)
398+
finally:
399+
consumer.close()
400+
management.delete_queue(stream_name)
410401

411402

412403
class MyMessageHandlerMessagePropertiesFilter(AMQPMessagingHandler):
@@ -468,11 +459,10 @@ def test_stream_filter_message_properties(
468459
# ack to terminate the consumer
469460
except ConsumerTestException:
470461
pass
471-
472-
if consumer is not None:
473-
consumer.close()
474-
475-
management.delete_queue(stream_name)
462+
finally:
463+
if consumer is not None:
464+
consumer.close()
465+
management.delete_queue(stream_name)
476466

477467

478468
class MyMessageHandlerApplicationPropertiesFilter(AMQPMessagingHandler):
@@ -529,11 +519,10 @@ def test_stream_filter_application_properties(
529519
# ack to terminate the consumer
530520
except ConsumerTestException:
531521
pass
532-
533-
if consumer is not None:
534-
consumer.close()
535-
536-
management.delete_queue(stream_name)
522+
finally:
523+
if consumer is not None:
524+
consumer.close()
525+
management.delete_queue(stream_name)
537526

538527

539528
class MyMessageHandlerSQLFilter(AMQPMessagingHandler):
@@ -605,11 +594,10 @@ def test_stream_filter_sql(connection: Connection, environment: Environment) ->
605594
# ack to terminate the consumer
606595
except ConsumerTestException:
607596
pass
608-
609-
if consumer is not None:
610-
consumer.close()
611-
612-
management.delete_queue(stream_name)
597+
finally:
598+
if consumer is not None:
599+
consumer.close()
600+
management.delete_queue(stream_name)
613601

614602

615603
class MyMessageHandlerMixingDifferentFilters(AMQPMessagingHandler):
@@ -681,8 +669,7 @@ def test_stream_filter_mixing_different(
681669
# ack to terminate the consumer
682670
except ConsumerTestException:
683671
pass
684-
685-
if consumer is not None:
686-
consumer.close()
687-
688-
management.delete_queue(stream_name)
672+
finally:
673+
if consumer is not None:
674+
consumer.close()
675+
management.delete_queue(stream_name)

0 commit comments

Comments
 (0)