From a5504520d1888bdb8e0314bc52e7205c425dd12c Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 11 Feb 2023 20:21:09 -0800 Subject: [PATCH] Explicitly reset format caches during testing This seems to be necessary primarily for consistency when running tests in parallel. Fixes #483 --- core/tests/tests_forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/tests/tests_forms.py b/core/tests/tests_forms.py index bd958cd0..1fed7a34 100644 --- a/core/tests/tests_forms.py +++ b/core/tests/tests_forms.py @@ -4,7 +4,7 @@ from django.core.management import call_command from django.test import TestCase from django.test import Client as HttpClient from django.utils import timezone -from django.utils.formats import get_format +from django.utils.formats import get_format, reset_format_cache from faker import Faker @@ -38,12 +38,14 @@ class FormsTestCaseBase(TestCase): @staticmethod def localdate_string(datetime=None): """Converts an object to a local date string for form input.""" + reset_format_cache() date_format = get_format("DATE_INPUT_FORMATS")[0] return timezone.localdate(datetime).strftime(date_format) @staticmethod def localtime_string(datetime=None): """Converts an object to a local time string for form input.""" + reset_format_cache() datetime_format = get_format("DATETIME_INPUT_FORMATS")[0] return timezone.localtime(datetime).strftime(datetime_format)