1313from .conftest import asynccontextmanager
1414from .test_pubsub import wait_for_message
1515
16+ pytestmark = pytest .mark .asyncio
17+
1618
1719@pytest .mark .onlynoncluster
1820class TestRedisAutoReleaseConnectionPool :
@@ -40,15 +42,13 @@ def has_no_connected_connections(pool: redis.ConnectionPool):
4042 for x in pool ._available_connections + list (pool ._in_use_connections )
4143 )
4244
43- @pytest .mark .asyncio
4445 async def test_auto_disconnect_redis_created_pool (self , r : redis .Redis ):
4546 new_conn = await self .create_two_conn (r )
4647 assert new_conn != r .connection
4748 assert self .get_total_connected_connections (r .connection_pool ) == 2
4849 await r .aclose ()
4950 assert self .has_no_connected_connections (r .connection_pool )
5051
51- @pytest .mark .asyncio
5252 async def test_do_not_auto_disconnect_redis_created_pool (self , r2 : redis .Redis ):
5353 assert r2 .auto_close_connection_pool is False , (
5454 "The connection pool should not be disconnected as a manually created "
@@ -62,7 +62,6 @@ async def test_do_not_auto_disconnect_redis_created_pool(self, r2: redis.Redis):
6262 assert len (r2 .connection_pool ._available_connections ) == 1
6363 assert r2 .connection_pool ._available_connections [0 ].is_connected
6464
65- @pytest .mark .asyncio
6665 async def test_auto_release_override_true_manual_created_pool (self , r : redis .Redis ):
6766 assert r .auto_close_connection_pool is True , "This is from the class fixture"
6867 await self .create_two_conn (r )
@@ -74,15 +73,13 @@ async def test_auto_release_override_true_manual_created_pool(self, r: redis.Red
7473 assert self .has_no_connected_connections (r .connection_pool )
7574
7675 @pytest .mark .parametrize ("auto_close_conn_pool" , [True , False ])
77- @pytest .mark .asyncio
7876 async def test_close_override (self , r : redis .Redis , auto_close_conn_pool ):
7977 r .auto_close_connection_pool = auto_close_conn_pool
8078 await self .create_two_conn (r )
8179 await r .aclose (close_connection_pool = True )
8280 assert self .has_no_connected_connections (r .connection_pool )
8381
8482 @pytest .mark .parametrize ("auto_close_conn_pool" , [True , False ])
85- @pytest .mark .asyncio
8683 async def test_negate_auto_close_client_pool (
8784 self , r : redis .Redis , auto_close_conn_pool
8885 ):
@@ -139,7 +136,6 @@ async def get_pool(
139136 finally :
140137 await pool .disconnect (inuse_connections = True )
141138
142- @pytest .mark .asyncio
143139 async def test_connection_creation (self ):
144140 connection_kwargs = {"foo" : "bar" , "biz" : "baz" }
145141 async with self .get_pool (
@@ -149,7 +145,6 @@ async def test_connection_creation(self):
149145 assert isinstance (connection , DummyConnection )
150146 assert connection .kwargs == connection_kwargs
151147
152- @pytest .mark .asyncio
153148 async def test_aclosing (self ):
154149 connection_kwargs = {"foo" : "bar" , "biz" : "baz" }
155150 pool = redis .ConnectionPool (
@@ -160,15 +155,13 @@ async def test_aclosing(self):
160155 async with aclosing (pool ):
161156 pass
162157
163- @pytest .mark .asyncio
164158 async def test_multiple_connections (self , master_host ):
165159 connection_kwargs = {"host" : master_host [0 ]}
166160 async with self .get_pool (connection_kwargs = connection_kwargs ) as pool :
167161 c1 = await pool .get_connection ()
168162 c2 = await pool .get_connection ()
169163 assert c1 != c2
170164
171- @pytest .mark .asyncio
172165 async def test_max_connections (self , master_host ):
173166 connection_kwargs = {"host" : master_host [0 ]}
174167 async with self .get_pool (
@@ -179,7 +172,6 @@ async def test_max_connections(self, master_host):
179172 with pytest .raises (redis .ConnectionError ):
180173 await pool .get_connection ()
181174
182- @pytest .mark .asyncio
183175 async def test_reuse_previously_released_connection (self , master_host ):
184176 connection_kwargs = {"host" : master_host [0 ]}
185177 async with self .get_pool (connection_kwargs = connection_kwargs ) as pool :
@@ -188,7 +180,6 @@ async def test_reuse_previously_released_connection(self, master_host):
188180 c2 = await pool .get_connection ()
189181 assert c1 == c2
190182
191- @pytest .mark .asyncio
192183 async def test_repr_contains_db_info_tcp (self ):
193184 connection_kwargs = {
194185 "host" : "localhost" ,
@@ -202,7 +193,6 @@ async def test_repr_contains_db_info_tcp(self):
202193 expected = "host=localhost,port=6379,db=1,client_name=test-client"
203194 assert expected in repr (pool )
204195
205- @pytest .mark .asyncio
206196 async def test_repr_contains_db_info_unix (self ):
207197 connection_kwargs = {"path" : "/abc" , "db" : 1 , "client_name" : "test-client" }
208198 async with self .get_pool (
@@ -228,7 +218,6 @@ async def get_pool(self, connection_kwargs=None, max_connections=10, timeout=20)
228218 finally :
229219 await pool .disconnect (inuse_connections = True )
230220
231- @pytest .mark .asyncio
232221 async def test_connection_creation (self , master_host ):
233222 connection_kwargs = {
234223 "foo" : "bar" ,
@@ -241,7 +230,6 @@ async def test_connection_creation(self, master_host):
241230 assert isinstance (connection , DummyConnection )
242231 assert connection .kwargs == connection_kwargs
243232
244- @pytest .mark .asyncio
245233 async def test_disconnect (self , master_host ):
246234 """A regression test for #1047"""
247235 connection_kwargs = {
@@ -254,15 +242,13 @@ async def test_disconnect(self, master_host):
254242 await pool .get_connection ()
255243 await pool .disconnect ()
256244
257- @pytest .mark .asyncio
258245 async def test_multiple_connections (self , master_host ):
259246 connection_kwargs = {"host" : master_host [0 ], "port" : master_host [1 ]}
260247 async with self .get_pool (connection_kwargs = connection_kwargs ) as pool :
261248 c1 = await pool .get_connection ()
262249 c2 = await pool .get_connection ()
263250 assert c1 != c2
264251
265- @pytest .mark .asyncio
266252 async def test_connection_pool_blocks_until_timeout (self , master_host ):
267253 """When out of connections, block for timeout seconds, then raise"""
268254 connection_kwargs = {"host" : master_host [0 ]}
@@ -279,7 +265,6 @@ async def test_connection_pool_blocks_until_timeout(self, master_host):
279265 assert asyncio .get_running_loop ().time () - start >= 0.05
280266 await c1 .disconnect ()
281267
282- @pytest .mark .asyncio
283268 async def test_connection_pool_blocks_until_conn_available (self , master_host ):
284269 """
285270 When out of connections, block until another connection is released
@@ -300,7 +285,6 @@ async def target():
300285 stop = asyncio .get_running_loop ().time ()
301286 assert (stop - start ) <= 0.2
302287
303- @pytest .mark .asyncio
304288 async def test_reuse_previously_released_connection (self , master_host ):
305289 connection_kwargs = {"host" : master_host [0 ]}
306290 async with self .get_pool (connection_kwargs = connection_kwargs ) as pool :
@@ -592,7 +576,6 @@ def get_connection(self):
592576
593577
594578class TestConnection :
595- @pytest .mark .asyncio
596579 async def test_on_connect_error (self ):
597580 """
598581 An error in Connection.on_connect should disconnect from the server
@@ -611,7 +594,6 @@ async def test_on_connect_error(self):
611594 @pytest .mark .onlynoncluster
612595 @skip_if_server_version_lt ("2.8.8" )
613596 @skip_if_redis_enterprise ()
614- @pytest .mark .asyncio
615597 async def test_busy_loading_disconnects_socket (self , r ):
616598 """
617599 If Redis raises a LOADING error, the connection should be
@@ -625,7 +607,6 @@ async def test_busy_loading_disconnects_socket(self, r):
625607 @pytest .mark .onlynoncluster
626608 @skip_if_server_version_lt ("2.8.8" )
627609 @skip_if_redis_enterprise ()
628- @pytest .mark .asyncio
629610 async def test_busy_loading_from_pipeline_immediate_command (self , r ):
630611 """
631612 BusyLoadingErrors should raise from Pipelines that execute a
@@ -644,7 +625,6 @@ async def test_busy_loading_from_pipeline_immediate_command(self, r):
644625 @pytest .mark .onlynoncluster
645626 @skip_if_server_version_lt ("2.8.8" )
646627 @skip_if_redis_enterprise ()
647- @pytest .mark .asyncio
648628 async def test_busy_loading_from_pipeline (self , r ):
649629 """
650630 BusyLoadingErrors should be raised from a pipeline execution
@@ -661,14 +641,12 @@ async def test_busy_loading_from_pipeline(self, r):
661641
662642 @skip_if_server_version_lt ("2.8.8" )
663643 @skip_if_redis_enterprise ()
664- @pytest .mark .asyncio
665644 async def test_read_only_error (self , r ):
666645 """READONLY errors get turned into ReadOnlyError exceptions"""
667646 with pytest .raises (redis .ReadOnlyError ):
668647 await r .execute_command ("DEBUG" , "ERROR" , "READONLY blah blah" )
669648
670649 @skip_if_redis_enterprise ()
671- @pytest .mark .asyncio
672650 async def test_oom_error (self , r ):
673651 """OOM errors get turned into OutOfMemoryError exceptions"""
674652 with pytest .raises (redis .OutOfMemoryError ):
@@ -701,7 +679,6 @@ def test_connect_from_url_unix(self):
701679 )
702680
703681 @skip_if_redis_enterprise ()
704- @pytest .mark .asyncio
705682 async def test_connect_no_auth_supplied_when_required (self , r ):
706683 """
707684 AuthenticationError should be raised when the server requires a
@@ -713,7 +690,6 @@ async def test_connect_no_auth_supplied_when_required(self, r):
713690 )
714691
715692 @skip_if_redis_enterprise ()
716- @pytest .mark .asyncio
717693 async def test_connect_invalid_password_supplied (self , r ):
718694 """AuthenticationError should be raised when sending the wrong password"""
719695 with pytest .raises (redis .AuthenticationError ):
@@ -744,14 +720,12 @@ def assert_interval_advanced(self, connection):
744720 diff = connection .next_health_check - asyncio .get_running_loop ().time ()
745721 assert self .interval >= diff > (self .interval - 1 )
746722
747- @pytest .mark .asyncio
748723 async def test_health_check_runs (self , r ):
749724 if r .connection :
750725 r .connection .next_health_check = asyncio .get_running_loop ().time () - 1
751726 await r .connection .check_health ()
752727 self .assert_interval_advanced (r .connection )
753728
754- @pytest .mark .asyncio
755729 async def test_arbitrary_command_invokes_health_check (self , r ):
756730 # invoke a command to make sure the connection is entirely setup
757731 if r .connection :
@@ -765,7 +739,6 @@ async def test_arbitrary_command_invokes_health_check(self, r):
765739
766740 self .assert_interval_advanced (r .connection )
767741
768- @pytest .mark .asyncio
769742 async def test_arbitrary_command_advances_next_health_check (self , r ):
770743 if r .connection :
771744 await r .get ("foo" )
@@ -775,7 +748,6 @@ async def test_arbitrary_command_advances_next_health_check(self, r):
775748 await r .get ("foo" )
776749 assert next_health_check < r .connection .next_health_check
777750
778- @pytest .mark .asyncio
779751 async def test_health_check_not_invoked_within_interval (self , r ):
780752 if r .connection :
781753 await r .get ("foo" )
@@ -786,7 +758,6 @@ async def test_health_check_not_invoked_within_interval(self, r):
786758 ping_call_spec = (("PING" ,), {"check_health" : False })
787759 assert ping_call_spec not in m .call_args_list
788760
789- @pytest .mark .asyncio
790761 async def test_health_check_in_pipeline (self , r ):
791762 async with r .pipeline (transaction = False ) as pipe :
792763 pipe .connection = await pipe .connection_pool .get_connection ()
@@ -798,7 +769,6 @@ async def test_health_check_in_pipeline(self, r):
798769 m .assert_any_call ("PING" , check_health = False )
799770 assert responses == [True , b"bar" ]
800771
801- @pytest .mark .asyncio
802772 async def test_health_check_in_transaction (self , r ):
803773 async with r .pipeline (transaction = True ) as pipe :
804774 pipe .connection = await pipe .connection_pool .get_connection ()
@@ -810,7 +780,6 @@ async def test_health_check_in_transaction(self, r):
810780 m .assert_any_call ("PING" , check_health = False )
811781 assert responses == [True , b"bar" ]
812782
813- @pytest .mark .asyncio
814783 async def test_health_check_in_watched_pipeline (self , r ):
815784 await r .set ("foo" , "bar" )
816785 async with r .pipeline (transaction = False ) as pipe :
@@ -835,7 +804,6 @@ async def test_health_check_in_watched_pipeline(self, r):
835804 assert responses == [True , b"not-bar" ]
836805 m .assert_any_call ("PING" , check_health = False )
837806
838- @pytest .mark .asyncio
839807 async def test_health_check_in_pubsub_before_subscribe (self , r ):
840808 """A health check happens before the first [p]subscribe"""
841809 p = r .pubsub ()
@@ -855,7 +823,6 @@ async def test_health_check_in_pubsub_before_subscribe(self, r):
855823 subscribe_message = await wait_for_message (p )
856824 assert subscribe_message ["type" ] == "subscribe"
857825
858- @pytest .mark .asyncio
859826 async def test_health_check_in_pubsub_after_subscribed (self , r ):
860827 """
861828 Pubsub can handle a new subscribe when it's time to check the
@@ -896,7 +863,6 @@ async def test_health_check_in_pubsub_after_subscribed(self, r):
896863 m .assert_any_call ("PING" , p .HEALTH_CHECK_MESSAGE , check_health = False )
897864 self .assert_interval_advanced (p .connection )
898865
899- @pytest .mark .asyncio
900866 async def test_health_check_in_pubsub_poll (self , r ):
901867 """
902868 Polling a pubsub connection that's subscribed will regularly
0 commit comments