Skip to content

Commit

Permalink
fix(session-keywords): timeout could be a touple #344
Browse files Browse the repository at this point in the history
  • Loading branch information
lucagiove committed Jun 6, 2023
1 parent e560999 commit 86c1922
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/RequestsLibrary/SessionKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,14 @@ def _check_status(expected_status, resp, msg=None):
msg = "{}Url: {} Expected status".format(msg, resp.url)
assert_equal(resp.status_code, expected_status, msg)

def _get_timeout(self, timeout):
return float(timeout) if timeout is not None else self.timeout
def _get_timeout(self, timeout):
result = timeout if timeout is not None else self.timeout

if result is None:
return None
if type(result) is tuple:
return (float(result[0]), float(result[1]))
return float(result)

def _capture_output(self):
if self.debug >= 1:
Expand Down
10 changes: 10 additions & 0 deletions utests/test_RequestsOnSessionKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ def test_common_request_with_float_timeout_override():
session, m_common_request = build_mocked_session_common_request(timeout=None)
m_common_request('get', session, '/', timeout=123.4)
session.get.assert_called_with('http://mocking.rules/', timeout=123.4, cookies={})

def test_common_request_with_touple_timeout():
session, m_common_request = build_mocked_session_common_request(timeout=(123.4, 432.1))
m_common_request('get', session, '/')
session.get.assert_called_with('http://mocking.rules/', timeout=(123.4, 432.1), cookies={})

def test_common_request_with_touple_timeout_override():
session, m_common_request = build_mocked_session_common_request(timeout=None)
m_common_request('get', session, '/', timeout=(123.4, 432.1))
session.get.assert_called_with('http://mocking.rules/', timeout=(123.4, 432.1), cookies={})

0 comments on commit 86c1922

Please sign in to comment.