mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
Fix test with Django 5 when pytz is available (#9715)
* Fix test with Django 5 when pytz is available * fix formatting * remove original condition Co-authored-by: Ülgen Sarıkavak <ulgens@users.noreply.github.com> * remove trailing whitespace * further improvements * let's not skip the pytz test - it should always be executed when testing against Django 4 * add comment to test requirements Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com> * simplify the pytz import as it should always be available * make isort happy --------- Co-authored-by: Ülgen Sarıkavak <ulgens@users.noreply.github.com> Co-authored-by: Bruno Alla <browniebroke@users.noreply.github.com>
This commit is contained in:
parent
2ae8c117da
commit
853969c69c
|
@ -5,3 +5,4 @@ pytest-django>=4.5.2,<5.0
|
|||
importlib-metadata<5.0
|
||||
# temporary pin of attrs
|
||||
attrs==22.1.0
|
||||
pytz # Remove when dropping support for Django<5.0
|
||||
|
|
|
@ -9,13 +9,9 @@ from enum import auto
|
|||
from unittest.mock import patch
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import django
|
||||
import pytest
|
||||
|
||||
try:
|
||||
import pytz
|
||||
except ImportError:
|
||||
pytz = None
|
||||
|
||||
from django.core.exceptions import ValidationError as DjangoValidationError
|
||||
from django.db.models import IntegerChoices, TextChoices
|
||||
from django.http import QueryDict
|
||||
|
@ -1624,7 +1620,10 @@ 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(
|
||||
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.
|
||||
|
@ -1638,7 +1637,6 @@ class TestPytzNaiveDayLightSavingTimeTimeZoneDateTimeField(FieldValues):
|
|||
}
|
||||
outputs = {}
|
||||
|
||||
if pytz:
|
||||
class MockTimezone(pytz.BaseTzInfo):
|
||||
@staticmethod
|
||||
def localize(value, is_dst):
|
||||
|
|
Loading…
Reference in New Issue
Block a user