Skip to content

Commit

Permalink
v2.0.5: support python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielburnworth committed Oct 15, 2024
1 parent b95b3a3 commit 28d180d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion farmbot/functions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def request_handling(self, response, make_request):

try:
response.json()
except requests.exceptions.JSONDecodeError:
except (json.JSONDecodeError, requests.exceptions.RequestException):
self.state.error += f" ({text})"
else:
self.state.error += f" ({json.dumps(response.json(), indent=2)})"
Expand Down
2 changes: 1 addition & 1 deletion farmbot/functions/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def wrapper(self, *args, **kwargs):
self.stop_listen()
return wrapper

@stop_listen_upon_interrupt
@stop_listen_upon_interrupt.__func__
def listen(self,
channel="#",
duration=None,
Expand Down
2 changes: 1 addition & 1 deletion farmbot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .functions.resources import Resources
from .functions.tools import ToolControls

VERSION = "2.0.4"
VERSION = "2.0.5"


class Farmbot():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
keywords = ["farmbot"]
description = "FarmBot Python package"
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
11 changes: 7 additions & 4 deletions tests/tests_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Farmbot class unit tests.
'''

import sys
import json
import unittest
from unittest.mock import Mock, patch, call
Expand Down Expand Up @@ -39,6 +40,10 @@
}


JSONDecodeError = requests.exceptions.JSONDecodeError if sys.version_info >= (
3, 10) else json.JSONDecodeError


class TestFarmbot(unittest.TestCase):
'''Farmbot tests'''

Expand Down Expand Up @@ -223,8 +228,7 @@ def test_api_string_error_response_handling(self, mock_request):
mock_response.status_code = 404
mock_response.reason = 'reason'
mock_response.text = 'error string'
mock_response.json.side_effect = requests.exceptions.JSONDecodeError(
'', '', 0)
mock_response.json.side_effect = JSONDecodeError('', '', 0)
mock_request.return_value = mock_response
response = self.fb.api_get('device')
mock_request.assert_called_once_with(
Expand All @@ -243,8 +247,7 @@ def test_api_string_error_response_handling_html(self, mock_request):
mock_response.status_code = 404
mock_response.reason = 'reason'
mock_response.text = '<html><h1>error0</h1><h2>error1</h2></html>'
mock_response.json.side_effect = requests.exceptions.JSONDecodeError(
'', '', 0)
mock_response.json.side_effect = JSONDecodeError('', '', 0)
mock_request.return_value = mock_response
response = self.fb.api_get('device')
mock_request.assert_called_once_with(
Expand Down

0 comments on commit 28d180d

Please sign in to comment.