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 1/6] 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 d574b07ebc..9f69a26a92 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -16,6 +16,7 @@ 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 @@ def test_should_render_date_time_in_default_timezone(self): 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. From 4e42975bbac0555cdb4dc37563e88ea15ab01996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Wed, 4 Jun 2025 15:38:05 +0200 Subject: [PATCH 2/6] fix formatting --- tests/test_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index 9f69a26a92..e6e9d17ad6 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1626,7 +1626,7 @@ def test_should_render_date_time_in_default_timezone(self): @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.") + 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. From 5b253461c84c251abe6ef7528899d41b73115098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Thu, 5 Jun 2025 08:26:39 +0200 Subject: [PATCH 3/6] remove original condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ülgen Sarıkavak --- tests/test_fields.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index e6e9d17ad6..fdd74dd972 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1625,8 +1625,10 @@ def test_should_render_date_time_in_default_timezone(self): assert rendered_date == rendered_date_in_timezone -@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.") +@pytest.mark.skipif( + condition=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. From 3817fb928227989235673f80d3aa87d5f0d1943f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Thu, 5 Jun 2025 08:28:50 +0200 Subject: [PATCH 4/6] remove trailing whitespace --- tests/test_fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fields.py b/tests/test_fields.py index fdd74dd972..bfa4f24d45 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1626,7 +1626,7 @@ def test_should_render_date_time_in_default_timezone(self): @pytest.mark.skipif( - condition=django.VERSION >= (5,), + condition=django.VERSION >= (5,), reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.", ) class TestPytzNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues): From d3ff351d37560cc63c4fb82b53e54b6224d5969a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Thu, 5 Jun 2025 11:12:50 +0200 Subject: [PATCH 5/6] further improvements --- tests/test_fields.py | 1 + tox.ini | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/test_fields.py b/tests/test_fields.py index bfa4f24d45..bd20ba64d7 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1625,6 +1625,7 @@ def test_should_render_date_time_in_default_timezone(self): assert rendered_date == rendered_date_in_timezone +@pytest.mark.skipif(condition=pytz is None, reason="pytz is not available.") @pytest.mark.skipif( condition=django.VERSION >= (5,), reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.", diff --git a/tox.ini b/tox.ini index 0adcee3a46..e9d8f9e372 100644 --- a/tox.ini +++ b/tox.ini @@ -17,6 +17,7 @@ setenv = PYTHONWARNINGS=once deps = django42: Django>=4.2,<5.0 + django42: pytz django50: Django>=5.0,<5.1 django51: Django>=5.1,<5.2 django52: Django>=5.2,<6.0 From a0fbdbd30e2b1d4e2adfbfbf283925d95f3e34f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kul=C3=ADk?= Date: Thu, 5 Jun 2025 12:52:37 +0200 Subject: [PATCH 6/6] let's not skip the pytz test - it should always be executed when testing against Django 4 --- requirements/requirements-testing.txt | 1 + tests/test_fields.py | 1 - tox.ini | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements/requirements-testing.txt b/requirements/requirements-testing.txt index 2b39316a00..b435c0f600 100644 --- a/requirements/requirements-testing.txt +++ b/requirements/requirements-testing.txt @@ -5,3 +5,4 @@ pytest-django>=4.5.2,<5.0 importlib-metadata<5.0 # temporary pin of attrs attrs==22.1.0 +pytz diff --git a/tests/test_fields.py b/tests/test_fields.py index bd20ba64d7..bfa4f24d45 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1625,7 +1625,6 @@ def test_should_render_date_time_in_default_timezone(self): assert rendered_date == rendered_date_in_timezone -@pytest.mark.skipif(condition=pytz is None, reason="pytz is not available.") @pytest.mark.skipif( condition=django.VERSION >= (5,), reason="Django 5.0 has removed pytz; this test should eventually be able to get removed.", diff --git a/tox.ini b/tox.ini index e9d8f9e372..0adcee3a46 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,6 @@ setenv = PYTHONWARNINGS=once deps = django42: Django>=4.2,<5.0 - django42: pytz django50: Django>=5.0,<5.1 django51: Django>=5.1,<5.2 django52: Django>=5.2,<6.0