Skip to content

Commit 418c89f

Browse files
committed
Fixture to patch itersize.
1 parent 60500d1 commit 418c89f

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/test_backend.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@
1717
from django_redis.serializers.msgpack import MSGPackSerializer
1818

1919

20+
@pytest.fixture
21+
def patch_itersize():
22+
# destroy cache to force recreation with overriden settings
23+
del caches["default"]
24+
with override_settings(DJANGO_REDIS_SCAN_ITERSIZE=30):
25+
yield
26+
# destroy cache to force recreation with original settings
27+
del caches["default"]
28+
29+
2030
class TestDjangoRedisCache:
2131
def test_setnx(self, cache: RedisCache):
2232
# we should ensure there is no test_key_nx in redis
@@ -497,12 +507,8 @@ def test_delete_pattern_with_custom_count(self, client_mock, cache: RedisCache):
497507
client_mock.delete_pattern.assert_called_once_with("*foo-a*", itersize=2)
498508

499509
@patch("django_redis.cache.RedisCache.client")
500-
@override_settings(DJANGO_REDIS_SCAN_ITERSIZE=30)
501510
def test_delete_pattern_with_settings_default_scan_count(
502-
self,
503-
client_mock,
504-
cache: RedisCache,
505-
settings: SettingsWrapper,
511+
self, client_mock, patch_itersize, cache: RedisCache, settings: SettingsWrapper,
506512
):
507513
for key in ["foo-aa", "foo-ab", "foo-bb", "foo-bc"]:
508514
cache.set(key, "foo")

0 commit comments

Comments
 (0)