Skip to content

Commit

Permalink
tests: make test independent of global state (#9446)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering committed May 28, 2024
1 parent b32a260 commit c638950
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/console/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ def test_application_verify_cache_flag_at_install(
disable_cache: bool,
set_project_context: SetProjectContext,
) -> None:
import poetry.utils.authenticator

# Set default authenticator to None so that it is recreated for each test
# and we get a consistent call_count.
poetry.utils.authenticator._authenticator = None

with set_project_context("sample_project"):
app = Application()

Expand All @@ -129,8 +135,9 @@ def test_application_verify_cache_flag_at_install(

tester.execute(command)

assert spy.call_count == 2
for call in spy.mock_calls:
# The third call is the default authenticator, which ignores the cache flag.
assert spy.call_count == 3
for call in spy.mock_calls[:2]:
(name, args, kwargs) = call
assert "disable_cache" in kwargs
assert disable_cache is kwargs["disable_cache"]

0 comments on commit c638950

Please sign in to comment.