diff --git a/fix-tests.patch b/fix-tests.patch new file mode 100644 index 0000000..8dcaa70 --- /dev/null +++ b/fix-tests.patch @@ -0,0 +1,72 @@ +From 0b50ee6721155ce0f652d4c1f47dcbb10c191894 Mon Sep 17 00:00:00 2001 +From: Mike +Date: Mon, 4 Dec 2023 17:48:36 -0800 +Subject: [PATCH] Fix tests (#769) + +--- + rest_framework_simplejwt/utils.py | 5 ++--- + tests/test_init.py | 5 ++--- + tests/test_utils.py | 11 ++++------- + 3 files changed, 8 insertions(+), 13 deletions(-) + +Index: djangorestframework_simplejwt-5.3.1/rest_framework_simplejwt/utils.py +=================================================================== +--- djangorestframework_simplejwt-5.3.1.orig/rest_framework_simplejwt/utils.py ++++ djangorestframework_simplejwt-5.3.1/rest_framework_simplejwt/utils.py +@@ -5,7 +5,6 @@ from typing import Callable + + from django.conf import settings + from django.utils.functional import lazy +-from django.utils.timezone import is_naive, make_aware + + + def get_md5_hash_password(password: str) -> str: +@@ -16,8 +15,8 @@ def get_md5_hash_password(password: str) + + + def make_utc(dt: datetime) -> datetime: +- if settings.USE_TZ and is_naive(dt): +- return make_aware(dt, timezone=timezone.utc) ++ if settings.USE_TZ and dt.tzinfo is None: ++ return dt.replace(tzinfo=timezone.utc) + + return dt + +Index: djangorestframework_simplejwt-5.3.1/tests/test_utils.py +=================================================================== +--- djangorestframework_simplejwt-5.3.1.orig/tests/test_utils.py ++++ djangorestframework_simplejwt-5.3.1/tests/test_utils.py +@@ -1,7 +1,6 @@ +-from datetime import datetime, timedelta ++from datetime import datetime, timedelta, timezone + + from django.test import TestCase +-from django.utils import timezone + from freezegun import freeze_time + + from rest_framework_simplejwt.utils import ( +@@ -24,11 +23,11 @@ class TestMakeUtc(TestCase): + + with self.settings(USE_TZ=False): + dt = make_utc(dt) +- self.assertTrue(timezone.is_naive(dt)) ++ self.assertTrue(dt.tzinfo is None) + + with self.settings(USE_TZ=True): + dt = make_utc(dt) +- self.assertTrue(timezone.is_aware(dt)) ++ self.assertTrue(dt.tzinfo is not None) + self.assertEqual(dt.utcoffset(), timedelta(seconds=0)) + + +@@ -39,9 +38,7 @@ class TestAwareUtcnow(TestCase): + with freeze_time(now): + # Should return aware utcnow if USE_TZ == True + with self.settings(USE_TZ=True): +- self.assertEqual( +- timezone.make_aware(now, timezone=timezone.utc), aware_utcnow() +- ) ++ self.assertEqual(now.replace(tzinfo=timezone.utc), aware_utcnow()) + + # Should return naive utcnow if USE_TZ == False + with self.settings(USE_TZ=False): diff --git a/python-djangorestframework-simplejwt.changes b/python-djangorestframework-simplejwt.changes index 35d986f..5d81843 100644 --- a/python-djangorestframework-simplejwt.changes +++ b/python-djangorestframework-simplejwt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Jul 19 11:26:13 UTC 2024 - Markéta Machová + +- Add upstream patch fix-tests.patch to fix tests with Django 5 + ------------------------------------------------------------------- Mon Jun 24 04:49:38 UTC 2024 - Steve Kowalik diff --git a/python-djangorestframework-simplejwt.spec b/python-djangorestframework-simplejwt.spec index 735f14d..24b4402 100644 --- a/python-djangorestframework-simplejwt.spec +++ b/python-djangorestframework-simplejwt.spec @@ -24,6 +24,8 @@ Summary: JSON Web Token authentication for Django REST Framework License: MIT URL: https://github.com/davesque/django-rest-framework-simplejwt Source: https://files.pythonhosted.org/packages/source/d/djangorestframework-simplejwt/djangorestframework_simplejwt-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/jazzband/djangorestframework-simplejwt/pull/769 Fix tests +Patch0: fix-tests.patch BuildRequires: %{python_module Django} BuildRequires: %{python_module PyJWT} BuildRequires: %{python_module djangorestframework}