From 54a10d5c36569dc027a41841f617fcc60c9396c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Mon, 27 May 2024 16:44:31 +0200 Subject: [PATCH] tests: make test independent of global state --- tests/console/test_application.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/console/test_application.py b/tests/console/test_application.py index b7d057b687c..ee95cda07b7 100644 --- a/tests/console/test_application.py +++ b/tests/console/test_application.py @@ -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() @@ -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"]