From 9090e32fd157fc8620929dbddbbc4a12079b6d36 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/console/test_application.py b/tests/console/test_application.py index b7d057b687c..e015798f498 100644 --- a/tests/console/test_application.py +++ b/tests/console/test_application.py @@ -116,6 +116,11 @@ def test_application_verify_cache_flag_at_install( disable_cache: bool, set_project_context: SetProjectContext, ) -> None: + import poetry.utils.authenticator + + # force set default authenticator to None so that it is recreated using patched config + poetry.utils.authenticator._authenticator = None + with set_project_context("sample_project"): app = Application() @@ -129,8 +134,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"]