Skip to content

Commit

Permalink
Enable Python 3.10 and Django 4.0 support
Browse files Browse the repository at this point in the history
Deprecate pytz and use dateutil.tz timezones
  • Loading branch information
aleksihakli committed Jan 25, 2022
1 parent a1cd420 commit 079732f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 46 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/test.yml
Expand Up @@ -10,12 +10,10 @@ jobs:
max-parallel: 5
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', 'pypy-3.8']
django-version: ['2.2', '3.2']
# Django 4.0+ is not supported yet due to dependencies
# django-version: ['2.2', '3.2', '4.0', 'main']
django-version: ['2.2', '3.2', '4.0']
include:
# Tox configuration for QA environment
- python-version: '3.8'
- python-version: '3.7'
django-version: 'qa'
# Django main
- python-version: '3.8'
Expand All @@ -31,10 +29,9 @@ jobs:
django-version: 'main'
experimental: true
exclude:
# Django 4.0+ is not supported yet due to dependencies
# # Exclude Django 4.0 for Python 3.7
# - python-version: '3.7'
# django-version: '4.0'
# Exclude Django 4.0 for Python 3.7
- python-version: '3.7'
django-version: '4.0'
# Exclude Django 2.2 for Python 3.10
- python-version: '3.10'
django-version: '2.2'
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.rst
Expand Up @@ -3,6 +3,13 @@ Changes
=======


1.8.3 (2022-01-25)
------------------

- Enable Python 3.10 and Django 4.0 support.
[aleksihakli]


1.8.2 (2022-01-13)
------------------

Expand Down
14 changes: 7 additions & 7 deletions django_ical/tests/test_feed.py
Expand Up @@ -6,8 +6,8 @@
from django.test import TestCase
from django.test.client import RequestFactory

from dateutil import tz
import icalendar
import pytz

from django_ical import utils
from django_ical.feedgenerator import ICal20Feed
Expand Down Expand Up @@ -358,8 +358,8 @@ class TestTimezoneFeed(TestICalFeed):
self.assertEqual(calendar["X-WR-TIMEZONE"], "Asia/Tokyo")

def test_timezone(self):
tokyo = pytz.timezone("Asia/Tokyo")
us_eastern = pytz.timezone("US/Eastern")
tokyo = tz.gettz("Asia/Tokyo") # also known as JST or Japan Standard Time
us_eastern = tz.gettz("US/Eastern") # also known as EDT or Eastern (Daylight) Time

class TestTimezoneFeed(TestItemsFeed):
def items(self):
Expand Down Expand Up @@ -403,28 +403,28 @@ def items(self):
calendar.subcomponents[0]["DTSTART"].to_ical(), b"20120501T180000"
)
self.assertEqual(
calendar.subcomponents[0]["DTSTART"].params["TZID"], "Asia/Tokyo"
calendar.subcomponents[0]["DTSTART"].params["TZID"], "JST"
)

self.assertEqual(
calendar.subcomponents[0]["DTEND"].to_ical(), b"20120501T200000"
)
self.assertEqual(
calendar.subcomponents[0]["DTEND"].params["TZID"], "Asia/Tokyo"
calendar.subcomponents[0]["DTEND"].params["TZID"], "JST"
)

self.assertEqual(
calendar.subcomponents[1]["DTSTART"].to_ical(), b"20120506T180000"
)
self.assertEqual(
calendar.subcomponents[1]["DTSTART"].params["TZID"], "US/Eastern"
calendar.subcomponents[1]["DTSTART"].params["TZID"], "EDT"
)

self.assertEqual(
calendar.subcomponents[1]["DTEND"].to_ical(), b"20120506T200000"
)
self.assertEqual(
calendar.subcomponents[1]["DTEND"].params["TZID"], "US/Eastern"
calendar.subcomponents[1]["DTEND"].params["TZID"], "EDT"
)

def test_file_name(self):
Expand Down
6 changes: 3 additions & 3 deletions django_ical/tests/test_recurrence.py
Expand Up @@ -4,6 +4,7 @@

from django.test import TestCase

from dateutil import tz
from dateutil.rrule import DAILY
from dateutil.rrule import MO
from dateutil.rrule import MONTHLY
Expand All @@ -13,7 +14,6 @@
from dateutil.rrule import YEARLY
from dateutil.rrule import rrule
from icalendar.prop import vRecur
import pytz
import recurrence

from django_ical import utils
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_ever_month_last_mo(self):

def test_every_week_until_jan_2007(self):
"""Repeat every week until January 1, 2007."""
utc = pytz.UTC
utc = tz.UTC
jan2007 = datetime.datetime(2007, 1, 1, 0, 0, tzinfo=utc)
vrecurr = utils.build_rrule(freq="WEEKLY", until=jan2007)
assert vrecurr["FREQ"] == "WEEKLY"
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_ever_month_second_last_fr(self):

def test_every_week_until_jan_2007(self):
"""Repeat every week until January 1, 2007."""
utc = pytz.UTC
utc = tz.UTC
vrecurr = utils.build_rrule_from_text("FREQ=WEEKLY;UNTIL=20070101T000000Z")
assert vrecurr["FREQ"] == ["WEEKLY"]
assert vrecurr["UNTIL"] == [datetime.datetime(2007, 1, 1, 0, 0, tzinfo=utc)]
Expand Down
6 changes: 2 additions & 4 deletions setup.py
Expand Up @@ -25,9 +25,7 @@
"Framework :: Django",
"Framework :: Django :: 2.2",
"Framework :: Django :: 3.2",
# Recurrence dependency first has to be dropped
# due to it being incompatible with Django 4.0
# "Framework :: Django :: 4.0",
"Framework :: Django :: 4.0",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
Expand All @@ -42,7 +40,7 @@
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
],
install_requires=["Django>=2.2", "icalendar>=4.0.3", "django-recurrence>=1.10.0"],
install_requires=["django>=2.2", "icalendar>=4.0.3", "django-recurrence>=1.11.1"],
packages=find_packages(),
test_suite="tests.main",
use_scm_version=True,
Expand Down
41 changes: 17 additions & 24 deletions tox.ini
@@ -1,55 +1,48 @@
[tox]
envlist =
py{37,38,39,py3}-dj22
py{37,38,39,310,py3}-dj32
# Django 4.0+ is not supported yet due to dependencies
# py{38,39,310,py3}-dj40
# py{38,39,310}-djmain
py310-djqa
py37-djqa
py{37,38,39,py38}-dj22
py{37,38,39,310,py38}-dj32
py{38,39,310,py38}-dj40
py{38,39,310,py38}-djmain

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
pypy3: pypy3
pypy-3.8: pypy38

[gh-actions:env]
DJANGO =
2.2: dj22
3.2: dj32
# 4.0: dj40
# main: djmain
4.0: dj40
main: djmain
qa: djqa

[testenv]
usedevelop = true
setenv =
PYTHONDONTWRITEBYTECODE=1
deps =
coverage==5.3
dj22: django>=2.2,<2.3
dj32: django>=3.1,<3.2
# Django 4.0+ is not supported yet due to dependencies
# dj40: django>=4.0,<4.1
# djmain: https://github.com/django/django/archive/main.tar.gz
usedevelop = true
dj40: django>=4.0,<4.1
djmain: https://github.com/django/django/archive/main.tar.gz
commands =
coverage run setup.py test
coverage report -m
setenv =
PYTHONDONTWRITEBYTECODE=1
# Django development version is allowed to fail the test matrix
ignore_outcome =
djmain: True
ignore_errors =
djmain: True

[testenv:py310-djqa]
[testenv:py37-djqa]
basepython = python3.7
ignore_errors = true
basepython = python3.10
skip_install = true
deps =
black==20.8b1
prospector==1.3.1
skip_install = true
commands =
prospector
black -t py38 --check --diff django_ical
black -t py37 --check --diff django_ical

0 comments on commit 079732f

Please sign in to comment.