tests: add callback to clear timezone cache on settings update (#89097)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Yann Weber 2024-04-04 14:31:45 +02:00
parent d03e1e7940
commit 5a90c4851b
1 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,9 @@
import django_webtest
import pytest
from django.core.signals import setting_changed
from django.dispatch import receiver
from chrono.utils.timezone import get_default_timezone
@pytest.fixture
@ -23,3 +27,10 @@ def nocache(settings):
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
@receiver(setting_changed)
def update_connections_time_zone(**kwargs):
if kwargs['setting'] == 'TIME_ZONE':
# Reset local time zone lru cache
get_default_timezone.cache_clear()