Skip to content

Commit

Permalink
use fewer asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
matin committed Dec 11, 2024
1 parent 08d620d commit 89e2b9a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions garth/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def _complete_login(
"""
# Parse ticket
m = re.search(r'embed\?ticket=([^"]+)"', html)
assert m, "Couldn't find ticket in response"
if not m:
raise GarthException(
"Couldn't find ticket in response"
) # pragma: no cover
ticket = m.group(1)

oauth1 = get_oauth1_token(ticket, client)
Expand Down Expand Up @@ -150,7 +153,8 @@ def login(
handle_mfa(client, SIGNIN_PARAMS, prompt_mfa)
title = get_title(client.last_resp.text)

assert title == "Success", f"Unexpected title: {title}"
if title != "Success":
raise GarthException(f"Unexpected title: {title}") # pragma: no cover
return _complete_login(client, client.last_resp.text)


Expand Down Expand Up @@ -269,5 +273,6 @@ def resume_login(
)

title = get_title(client.last_resp.text)
assert title == "Success", f"Unexpected title: {title}"
if title != "Success":
raise GarthException(f"Unexpected title: {title}") # pragma: no cover
return _complete_login(client, client.last_resp.text)

0 comments on commit 89e2b9a

Please sign in to comment.