Skip to content

Commit

Permalink
Allow client timeout to be a float
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundlam committed Nov 25, 2022
1 parent f06d805 commit 6e5d22c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pusher/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def __init__(

self._port = port or (443 if ssl else 80)

if not isinstance(timeout, six.integer_types):
raise TypeError("timeout should be an integer")
if not (isinstance(timeout, six.integer_types) or isinstance(timeout, float)):
raise TypeError("timeout should be an integer or a float")

self._timeout = timeout
self._json_encoder = json_encoder
Expand Down
7 changes: 7 additions & 0 deletions pusher_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def test_port_should_be_number(self):
self.assertRaises(TypeError, lambda: Client(
app_id=u'4', key=u'key', secret=u'secret', ssl=True, port=u'400'))

def test_timeout_should_be_number(self):
Client(app_id=u'4', key=u'key', secret=u'secret', timeout=1)
Client(app_id=u'4', key=u'key', secret=u'secret', timeout=3.14)

self.assertRaises(TypeError, lambda: Client(
app_id=u'4', key=u'key', secret=u'secret', timeout=u'1'))


def test_port_behaviour(self):
conf = Client(app_id=u'4', key=u'key', secret=u'secret', ssl=True)
Expand Down

0 comments on commit 6e5d22c

Please sign in to comment.