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
|
import requests
|
||||||
from requests.adapters import HTTPAdapter
|
from requests.adapters import HTTPAdapter
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError as RequestConnectionError
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("ft_rest_client")
|
logger = logging.getLogger("ft_rest_client")
|
||||||
@@ -53,7 +53,7 @@ class FtRestClient:
|
|||||||
resp = self._session.request(method, url, headers=hd, data=json.dumps(data))
|
resp = self._session.request(method, url, headers=hd, data=json.dumps(data))
|
||||||
# return resp.text
|
# return resp.text
|
||||||
return resp.json()
|
return resp.json()
|
||||||
except ConnectionError:
|
except RequestConnectionError:
|
||||||
logger.warning(f"Connection error - could not connect to {netloc}.")
|
logger.warning(f"Connection error - could not connect to {netloc}.")
|
||||||
|
|
||||||
def _get(self, apipath, params: ParamsT = None):
|
def _get(self, apipath, params: ParamsT = None):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import re
|
|||||||
from unittest.mock import ANY, MagicMock
|
from unittest.mock import ANY, MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError as RequestsConnectionError
|
||||||
|
|
||||||
from freqtrade_client import FtRestClient
|
from freqtrade_client import FtRestClient
|
||||||
from freqtrade_client.ft_client import add_arguments, main_exec
|
from freqtrade_client.ft_client import add_arguments, main_exec
|
||||||
@@ -45,7 +45,7 @@ def test_FtRestClient_call_invalid(caplog):
|
|||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
client._call("PUTTY", "/dummytest")
|
client._call("PUTTY", "/dummytest")
|
||||||
|
|
||||||
client._session.request = MagicMock(side_effect=ConnectionError())
|
client._session.request = MagicMock(side_effect=RequestsConnectionError())
|
||||||
client._call("GET", "/dummytest")
|
client._call("GET", "/dummytest")
|
||||||
|
|
||||||
assert log_has_re("Connection error", caplog)
|
assert log_has_re("Connection error", caplog)
|
||||||
|
|||||||
Reference in New Issue
Block a user