Skip to content

Commit

Permalink
Remove pytz use, start testing on django 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Dec 5, 2023
1 parent 115f821 commit e786528
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
matrix:
python-version: ["3.10.x", "3.11.x"]
pg-version: ["14", "15"]
django-version: ["4.1.x", "4.2.x"]
django-version: ["4.1.x", "4.2.x", "5.0.x"]
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
137 changes: 63 additions & 74 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ repository = "http://github.com/nyaruka/smartmin"

[tool.poetry.dependencies]
python = "^3.10"
Django = ">= 4.0, < 5.0"
Django = ">= 4.0, < 5.1"
celery = ">= 5.1"
pytz = "*"
redis = ">= 3.5.3"
sqlparse = "^0.4.1"
xlrd = "^1.2.0"
Expand Down
12 changes: 5 additions & 7 deletions test_runner/blog/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime, timedelta
from unittest.mock import patch

import pytz
from zoneinfo import ZoneInfo

from django.conf import settings
from django.contrib.auth.models import Group, User
Expand Down Expand Up @@ -485,8 +485,8 @@ def test_management(self):
self.assertEquals(13, authors.permissions.all().count())

def test_smart_model(self):
d1 = datetime(2016, 12, 31, 9, 20, 30, 123456, tzinfo=pytz.timezone("Africa/Kigali"))
d2 = datetime(2017, 1, 10, 10, 20, 30, 123456, tzinfo=pytz.timezone("Africa/Kigali"))
d1 = datetime(2016, 12, 31, 9, 20, 30, 123456, tzinfo=ZoneInfo("Africa/Kigali"))
d2 = datetime(2017, 1, 10, 10, 20, 30, 123456, tzinfo=ZoneInfo("Africa/Kigali"))
d3 = timezone.now()

p1 = Post.objects.create(
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def setUp(self):
def test_value_from_view(self):
context = dict(view=self.read_view, object=self.post)
self.assertEquals(self.post.title, get_value_from_view(context, "title"))
local_created = self.post.created_on.replace(tzinfo=pytz.utc).astimezone(pytz.timezone("Africa/Kigali"))
local_created = self.post.created_on.replace(tzinfo=timezone.utc).astimezone(ZoneInfo("Africa/Kigali"))
self.assertEquals(local_created.strftime("%b %d, %Y %H:%M"), get_value_from_view(context, "created_on"))

def test_view_as_json(self):
Expand All @@ -1166,8 +1166,6 @@ def test_map(self):
self.assertEquals("title: {title} id: {id}".format(**kwargs), map("title: %(title)s id: %(id)d", self.post))

def test_gmail_time(self):
import pytz

from smartmin.templatetags.smartmin import gmail_time

# given the time as now, should display "Hour:Minutes AM|PM" eg. "5:05 pm"
Expand All @@ -1185,7 +1183,7 @@ def test_gmail_time(self):
self.assertEquals(test_date.strftime("%b") + " 2", gmail_time(test_date, now))

# but a different year is different
jan_2 = datetime(2012, 1, 2, 17, 5, 0, 0).replace(tzinfo=pytz.utc)
jan_2 = datetime(2012, 1, 2, 17, 5, 0, 0).replace(tzinfo=timezone.utc)
self.assertEquals("2/1/12", gmail_time(jan_2, now))

def test_user_as_string(self):
Expand Down

0 comments on commit e786528

Please sign in to comment.