From 656d83562fb0691a9b0e079eabb988010c6031db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Wed, 4 Jun 2025 15:31:27 +0200 Subject: [PATCH] Fix test with Django 5 when pytz is available --- tests/test_fields.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index d574b07eb..9f69a26a9 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -16,6 +16,7 @@ try: except ImportError: pytz = None +import django from django.core.exceptions import ValidationError as DjangoValidationError from django.db.models import IntegerChoices, TextChoices from django.http import QueryDict @@ -1624,7 +1625,8 @@ class TestCustomTimezoneForDateTimeField(TestCase): assert rendered_date == rendered_date_in_timezone -@pytest.mark.skipif(pytz is None, reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.") +@pytest.mark.skipif(pytz is None or django.VERSION >= (5,), + reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.") class TestPytzNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues): """ Invalid values for `DateTimeField` with datetime in DST shift (non-existing or ambiguous) and timezone with DST.