Skip to content

Commit c0d2146

Browse files
committed
Update test_endpoint.py
1 parent 43b7655 commit c0d2146

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

tests/test_endpoint.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,12 @@ def test_proxy_error_propagates(self):
250250
# ---------------------------------------------------------------------------
251251

252252
class TestCache:
253-
def test_second_call_uses_cache(self, mocker):
254-
# Prime the cache with the first call, then spy on open() to confirm
255-
# the second call does NOT read the file again.
253+
def test_second_call_uses_cache(self, reset_cache):
254+
from unittest.mock import patch, MagicMock
256255
Endpoint.get_contentstack_endpoint("na", "contentDelivery")
257-
spy = mocker.patch("builtins.open", wraps=open)
258-
Endpoint.get_contentstack_endpoint("eu", "contentDelivery")
259-
# The cached path must not trigger any file reads.
260-
spy.assert_not_called()
256+
with patch("builtins.open", wraps=open) as spy:
257+
Endpoint.get_contentstack_endpoint("eu", "contentDelivery")
258+
spy.assert_not_called()
261259

262260
def test_reset_cache_clears_data(self):
263261
Endpoint.get_contentstack_endpoint("na") # primes cache

0 commit comments

Comments
 (0)