From 9ed587567a2806c6169fa1bc9f48b8ad21cabe8e Mon Sep 17 00:00:00 2001 From: Kevin Cameron Grismore Date: Thu, 1 Feb 2024 23:05:10 -0600 Subject: [PATCH] clear cache for testing call count --- tests/test_worker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_worker.py b/tests/test_worker.py index ba68a36..600d07d 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -47,7 +47,10 @@ from prefect_kubernetes import KubernetesWorker from prefect_kubernetes.utilities import _slugify_label_value, _slugify_name -from prefect_kubernetes.worker import KubernetesWorkerJobConfiguration +from prefect_kubernetes.worker import ( + KubernetesWorkerJobConfiguration, + _get_cached_kubernetes_client, +) FAKE_CLUSTER = "fake-cluster" MOCK_CLUSTER_UID = "1234" @@ -1978,6 +1981,7 @@ async def test_defaults_to_incluster_config( mock_cluster_config, mock_batch_client, ): + _get_cached_kubernetes_client.cache_clear() mock_watch.stream = _mock_pods_stream_that_returns_running_pod async with KubernetesWorker(work_pool_name="test") as k8s_worker: @@ -1995,6 +1999,7 @@ async def test_uses_cluster_config_if_not_in_cluster( mock_cluster_config, mock_batch_client, ): + _get_cached_kubernetes_client.cache_clear() mock_watch.stream = _mock_pods_stream_that_returns_running_pod mock_cluster_config.load_incluster_config.side_effect = ConfigException() async with KubernetesWorker(work_pool_name="test") as k8s_worker: