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,7 @@ 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 ()
109+ # event.connection.close()
109110 raise ConsumerTestException ("consumed" )
110111
111112
@@ -123,7 +124,7 @@ def on_message(self, event: Event):
123124 self .delivery_context .accept (event )
124125 self ._received = self ._received + 1
125126 if self ._received == 10 :
126- event .connection .close ()
127+ # event.connection.close()
127128 raise ConsumerTestException ("consumed" )
128129
129130
@@ -136,8 +137,8 @@ def __init__(self):
136137 def on_message (self , event : Event ):
137138 self ._received = self ._received + 1
138139 if self ._received == 1000 :
139- event .receiver .close ()
140- event .connection .close ()
140+ # event.receiver.close()
141+ # event.connection.close()
141142 # Workaround to terminate the Consumer and notify the test when all messages are consumed
142143 raise ConsumerTestException ("consumed" )
143144
@@ -152,7 +153,7 @@ def on_message(self, event: Event):
152153 self .delivery_context .discard (event )
153154 self ._received = self ._received + 1
154155 if self ._received == 1000 :
155- event .connection .close ()
156+ # event.connection.close()
156157 raise ConsumerTestException ("consumed" )
157158
158159
@@ -168,7 +169,7 @@ def on_message(self, event: Event):
168169 self .delivery_context .discard_with_annotations (event , annotations )
169170 self ._received = self ._received + 1
170171 if self ._received == 1000 :
171- event .connection .close ()
172+ # event.connection.close()
172173 raise ConsumerTestException ("consumed" )
173174
174175
@@ -182,7 +183,7 @@ def on_message(self, event: Event):
182183 self .delivery_context .requeue (event )
183184 self ._received = self ._received + 1
184185 if self ._received == 1000 :
185- event .connection .close ()
186+ # event.connection.close()
186187 raise ConsumerTestException ("consumed" )
187188
188189
@@ -198,7 +199,7 @@ def on_message(self, event: Event):
198199 self .delivery_context .requeue_with_annotations (event , annotations )
199200 self ._received = self ._received + 1
200201 if self ._received == 1000 :
201- event .connection .close ()
202+ # event.connection.close()
202203 raise ConsumerTestException ("consumed" )
203204
204205
@@ -214,5 +215,5 @@ def on_message(self, event: Event):
214215 self .delivery_context .requeue_with_annotations (event , annotations )
215216 self ._received = self ._received + 1
216217 if self ._received == 1000 :
217- event .connection .close ()
218+ # event.connection.close()
218219 raise ConsumerTestException ("consumed" )
0 commit comments