Skip to content

Commit

Permalink
Fixes #305 with try catch instead of if
Browse files Browse the repository at this point in the history
  • Loading branch information
lucagiove committed Nov 11, 2020
1 parent ae9c3bb commit 48b0ef6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions atests/issues/305.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*** Settings ***
Library ../../src/RequestsLibrary/RequestsKeywords.py


*** Test Cases ***
Test NTLM Session without installed library
${auth}= Create List 1 2 3
Run Keyword And Expect Error requests_ntlm module not installed Create Ntlm Session ntlm http://localhost:80 ${auth}
8 changes: 5 additions & 3 deletions src/RequestsLibrary/RequestsKeywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,11 @@ def create_ntlm_session(
eg. set to [502, 503] to retry requests if those status are returned.
Note that max_retries must be greater than 0.
"""
if not HttpNtlmAuth:
raise AssertionError('Requests NTLM module not loaded')
elif len(auth) != 3:
try:
HttpNtlmAuth
except NameError:
raise AssertionError('requests_ntlm module not installed')
if len(auth) != 3:
raise AssertionError('Incorrect number of authentication arguments'
' - expected 3, got {}'.format(len(auth)))
else:
Expand Down
2 changes: 1 addition & 1 deletion src/RequestsLibrary/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '0.7.1'
VERSION = '0.7.2'

0 comments on commit 48b0ef6

Please sign in to comment.