mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-19 21:40:24 +00:00
chore: update imports to prevent shadowing internal exceptions
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user