1515
1616@pytest .fixture ()
1717def environment (pytestconfig ):
18- environment = Environment ()
18+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
1919 try :
2020 yield environment
2121
@@ -25,8 +25,8 @@ def environment(pytestconfig):
2525
2626@pytest .fixture ()
2727def connection (pytestconfig ):
28- environment = Environment ()
29- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
28+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
29+ connection = environment .connection ()
3030 connection .dial ()
3131 try :
3232 yield connection
@@ -37,17 +37,18 @@ def connection(pytestconfig):
3737
3838@pytest .fixture ()
3939def connection_ssl (pytestconfig ):
40- environment = Environment ()
4140 ca_cert_file = ".ci/certs/ca_certificate.pem"
4241 client_cert = ".ci/certs/client_certificate.pem"
4342 client_key = ".ci/certs/client_key.pem"
44- connection = environment .connection (
43+
44+ environment = Environment (
4545 "amqps://guest:guest@localhost:5671/" ,
4646 ssl_context = SslConfigurationContext (
4747 ca_cert = ca_cert_file ,
4848 client_cert = ClientCert (client_cert = client_cert , client_key = client_key ),
4949 ),
5050 )
51+ connection = environment .connection ()
5152 connection .dial ()
5253 try :
5354 yield connection
@@ -58,8 +59,8 @@ def connection_ssl(pytestconfig):
5859
5960@pytest .fixture ()
6061def management (pytestconfig ):
61- environment = Environment ()
62- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
62+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
63+ connection = environment .connection ()
6364 connection .dial ()
6465 try :
6566 management = connection .management ()
@@ -71,8 +72,8 @@ def management(pytestconfig):
7172
7273@pytest .fixture ()
7374def consumer (pytestconfig ):
74- environment = Environment ()
75- connection = environment .connection ("amqp://guest:guest@localhost:5672/" )
75+ environment = Environment (uri = "amqp://guest:guest@localhost:5672/" )
76+ connection = environment .connection ()
7677 connection .dial ()
7778 try :
7879 queue_name = "test-queue"
@@ -105,7 +106,6 @@ def on_message(self, event: Event):
105106 self .delivery_context .accept (event )
106107 self ._received = self ._received + 1
107108 if self ._received == 1000 :
108- event .connection .close ()
109109 raise ConsumerTestException ("consumed" )
110110
111111
@@ -123,7 +123,6 @@ def on_message(self, event: Event):
123123 self .delivery_context .accept (event )
124124 self ._received = self ._received + 1
125125 if self ._received == 10 :
126- event .connection .close ()
127126 raise ConsumerTestException ("consumed" )
128127
129128
@@ -136,8 +135,6 @@ def __init__(self):
136135 def on_message (self , event : Event ):
137136 self ._received = self ._received + 1
138137 if self ._received == 1000 :
139- event .receiver .close ()
140- event .connection .close ()
141138 # Workaround to terminate the Consumer and notify the test when all messages are consumed
142139 raise ConsumerTestException ("consumed" )
143140
@@ -152,7 +149,6 @@ def on_message(self, event: Event):
152149 self .delivery_context .discard (event )
153150 self ._received = self ._received + 1
154151 if self ._received == 1000 :
155- event .connection .close ()
156152 raise ConsumerTestException ("consumed" )
157153
158154
@@ -168,7 +164,6 @@ def on_message(self, event: Event):
168164 self .delivery_context .discard_with_annotations (event , annotations )
169165 self ._received = self ._received + 1
170166 if self ._received == 1000 :
171- event .connection .close ()
172167 raise ConsumerTestException ("consumed" )
173168
174169
@@ -182,7 +177,7 @@ def on_message(self, event: Event):
182177 self .delivery_context .requeue (event )
183178 self ._received = self ._received + 1
184179 if self ._received == 1000 :
185- event .connection .close ()
180+ # event.connection.close()
186181 raise ConsumerTestException ("consumed" )
187182
188183
@@ -198,7 +193,6 @@ def on_message(self, event: Event):
198193 self .delivery_context .requeue_with_annotations (event , annotations )
199194 self ._received = self ._received + 1
200195 if self ._received == 1000 :
201- event .connection .close ()
202196 raise ConsumerTestException ("consumed" )
203197
204198
@@ -214,5 +208,4 @@ def on_message(self, event: Event):
214208 self .delivery_context .requeue_with_annotations (event , annotations )
215209 self ._received = self ._received + 1
216210 if self ._received == 1000 :
217- event .connection .close ()
218211 raise ConsumerTestException ("consumed" )
0 commit comments