diff --git a/ft_client/freqtrade_client/ft_rest_client.py b/ft_client/freqtrade_client/ft_rest_client.py index 1763cc1a9..851583ee0 100755 --- a/ft_client/freqtrade_client/ft_rest_client.py +++ b/ft_client/freqtrade_client/ft_rest_client.py @@ -12,7 +12,7 @@ from urllib.parse import urlencode, urlparse, urlunparse import requests from requests.adapters import HTTPAdapter -from requests.exceptions import ConnectionError +from requests.exceptions import ConnectionError as RequestConnectionError logger = logging.getLogger("ft_rest_client") @@ -53,7 +53,7 @@ class FtRestClient: resp = self._session.request(method, url, headers=hd, data=json.dumps(data)) # return resp.text return resp.json() - except ConnectionError: + except RequestConnectionError: logger.warning(f"Connection error - could not connect to {netloc}.") def _get(self, apipath, params: ParamsT = None): diff --git a/ft_client/test_client/test_rest_client.py b/ft_client/test_client/test_rest_client.py index 1a709b9c5..c1af6ded2 100644 --- a/ft_client/test_client/test_rest_client.py +++ b/ft_client/test_client/test_rest_client.py @@ -2,7 +2,7 @@ import re from unittest.mock import ANY, MagicMock import pytest -from requests.exceptions import ConnectionError +from requests.exceptions import ConnectionError as RequestsConnectionError from freqtrade_client import FtRestClient from freqtrade_client.ft_client import add_arguments, main_exec @@ -45,7 +45,7 @@ def test_FtRestClient_call_invalid(caplog): with pytest.raises(ValueError): client._call("PUTTY", "/dummytest") - client._session.request = MagicMock(side_effect=ConnectionError()) + client._session.request = MagicMock(side_effect=RequestsConnectionError()) client._call("GET", "/dummytest") assert log_has_re("Connection error", caplog)