Skip to content

Commit

Permalink
refactor: move initial context setting out of try block
Browse files Browse the repository at this point in the history
  • Loading branch information
maffettone committed Nov 25, 2024
1 parent 3011c9c commit 39f1d0d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tiled/_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@ def enter_username_password(username, password):
... # Run code that calls prompt_for_credentials and subsequently getpass.getpass().
"""

original_prompt = context.PROMPT_FOR_REAUTHENTICATION
original_credentials = context.prompt_for_credentials
context.PROMPT_FOR_REAUTHENTICATION = True
context.prompt_for_credentials = lambda u, p: (username, password)
try:
original_prompt = context.PROMPT_FOR_REAUTHENTICATION
original_credentials = context.prompt_for_credentials
context.PROMPT_FOR_REAUTHENTICATION = True
context.prompt_for_credentials = lambda u, p: (username, password)
# Ensures that raise in calling routine does not prevent context from being exited.
yield
finally:
context.PROMPT_FOR_REAUTHENTICATION = original_prompt
Expand Down

0 comments on commit 39f1d0d

Please sign in to comment.