Skip to content

Commit 8f6d4d4

Browse files
committed
Clear retry_on_error list at the end of each test to fix tests
1 parent 40095e3 commit 8f6d4d4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_connection.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def test_disconnect__close_OSError(self):
7979
mock_sock.close.assert_called_once()
8080
assert conn._sock is None
8181

82+
def clear(self, conn):
83+
conn.retry_on_error.clear()
84+
8285
def test_retry_connect_on_timeout_error(self):
8386
"""Test that the _connect function is retried in case of a timeout"""
8487
conn = Connection(retry_on_timeout=True, retry=Retry(NoBackoff(), 3))
@@ -95,6 +98,7 @@ def mock_connect():
9598
conn._connect.side_effect = mock_connect
9699
conn.connect()
97100
assert conn._connect.call_count == 3
101+
self.clear(conn)
98102

99103
def test_connect_without_retry_on_os_error(self):
100104
"""Test that the _connect function is not being retried in case of a OSError"""
@@ -104,15 +108,17 @@ def test_connect_without_retry_on_os_error(self):
104108
with pytest.raises(ConnectionError):
105109
conn.connect()
106110
assert _connect.call_count == 1
111+
self.clear(conn)
107112

108113
def test_connect_timeout_error_without_retry(self):
109114
"""Test that the _connect function is not being retried if retry_on_timeout is
110-
set to False (default value)"""
111-
conn = Connection()
115+
set to False"""
116+
conn = Connection(retry_on_timeout=False)
112117
conn._connect = mock.Mock()
113118
conn._connect.side_effect = socket.timeout
114119

115120
with pytest.raises(TimeoutError) as e:
116121
conn.connect()
117122
assert conn._connect.call_count == 1
118123
assert str(e.value) == "Timeout connecting to server"
124+
self.clear(conn)

0 commit comments

Comments
 (0)