Skip to content

Commit 0e501f9

Browse files
Fix code formatting in test_max_connections_error.py
- Format code with ruff to comply with style guidelines - Fix line length issues - Change single quotes to double quotes - Add proper spacing between methods for better readability
1 parent 37a6cd5 commit 0e501f9

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

tests/test_max_connections_error.py

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class DummyConnection(ConnectionInterface):
88
"""A dummy connection class for testing that doesn't actually connect to Redis"""
9+
910
def __init__(self, *args, **kwargs):
1011
self.connected = False
1112

@@ -15,23 +16,43 @@ def connect(self):
1516
def disconnect(self):
1617
self.connected = False
1718

18-
def register_connect_callback(self, callback): pass
19-
def deregister_connect_callback(self, callback): pass
20-
def set_parser(self, parser_class): pass
21-
def get_protocol(self): return 2
22-
def on_connect(self): pass
23-
def check_health(self): return True
24-
def send_packed_command(self, command, check_health=True): pass
25-
def send_command(self, *args, **kwargs): pass
26-
def can_read(self, timeout=0): return False
27-
def read_response(self, disable_decoding=False, **kwargs): return "PONG"
19+
def register_connect_callback(self, callback):
20+
pass
21+
22+
def deregister_connect_callback(self, callback):
23+
pass
24+
25+
def set_parser(self, parser_class):
26+
pass
27+
28+
def get_protocol(self):
29+
return 2
30+
31+
def on_connect(self):
32+
pass
33+
34+
def check_health(self):
35+
return True
36+
37+
def send_packed_command(self, command, check_health=True):
38+
pass
39+
40+
def send_command(self, *args, **kwargs):
41+
pass
42+
43+
def can_read(self, timeout=0):
44+
return False
45+
46+
def read_response(self, disable_decoding=False, **kwargs):
47+
return "PONG"
2848

2949

3050
@pytest.mark.onlynoncluster
3151
def test_max_connections_error_inheritance():
3252
"""Test that MaxConnectionsError is a subclass of ConnectionError"""
3353
assert issubclass(redis.MaxConnectionsError, redis.ConnectionError)
3454

55+
3556
@pytest.mark.onlynoncluster
3657
def test_connection_pool_raises_max_connections_error():
3758
"""Test that ConnectionPool raises MaxConnectionsError and not ConnectionError"""
@@ -43,7 +64,9 @@ def test_connection_pool_raises_max_connections_error():
4364
pool.get_connection()
4465

4566

46-
@pytest.mark.skipif(not hasattr(redis, "RedisCluster"), reason="RedisCluster not available")
67+
@pytest.mark.skipif(
68+
not hasattr(redis, "RedisCluster"), reason="RedisCluster not available"
69+
)
4770
def test_cluster_handles_max_connections_error():
4871
"""
4972
Test that RedisCluster doesn't reinitialize when MaxConnectionsError is raised
@@ -63,9 +86,11 @@ def test_cluster_handles_max_connections_error():
6386
connection = mock.MagicMock()
6487

6588
# Patch the get_connection function in the cluster module
66-
with mock.patch('redis.cluster.get_connection', return_value=connection):
89+
with mock.patch("redis.cluster.get_connection", return_value=connection):
6790
# Test MaxConnectionsError
68-
connection.send_command.side_effect = redis.MaxConnectionsError("Too many connections")
91+
connection.send_command.side_effect = redis.MaxConnectionsError(
92+
"Too many connections"
93+
)
6994

7095
# Call the method and check that the exception is raised
7196
with pytest.raises(redis.MaxConnectionsError):

0 commit comments

Comments
 (0)