Skip to content

Commit

Permalink
tests working with latest pytz version
Browse files Browse the repository at this point in the history
We had assumed that pytz versions would always follow the schema
year.month, but pytz 2022.2.1 broke that assumption and our code. We
should now be able to deal with pytz versions in the
year.month.anything.

fix #1180
  • Loading branch information
geier committed Sep 3, 2022
1 parent ccb8a09 commit f6c9b8a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -13,6 +13,8 @@ not released

* DROPPED support for python versions < 3.8
* UPDATED REQUIREMENT pytz is now required >= 2018.7
* NEW test REQUIREMENT: packaging
* FIX support in tests for pytz version numbers of the format year.month.minor
* FIX deleting of instances of recurring events in ikhal
* FIX if a `discover` collection is set to "readonly", discovered collections
will now inherit the readonly property
Expand Down
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -27,6 +27,7 @@
test_requirements = [
'freezegun',
'hypothesis',
'packaging',
'vdirsyncer',
]

Expand Down
8 changes: 0 additions & 8 deletions tests/conftest.py
Expand Up @@ -3,7 +3,6 @@
from time import sleep

import pytest
import pytz

from khal.custom_types import CalendarConfiguration
from khal.khalendar import CalendarCollection
Expand Down Expand Up @@ -144,13 +143,6 @@ def touch_and_mtime():
)


@pytest.fixture(scope='session')
def pytz_version():
"""Return the version of pytz as a tuple."""
year, month = pytz.__version__.split('.')
return int(year), int(month)


@pytest.fixture
def fix_caplog(monkeypatch):
"""Temporarily undoes the logging setup by click-log such that the caplog fixture can be used"""
Expand Down
5 changes: 3 additions & 2 deletions tests/event_test.py
Expand Up @@ -6,6 +6,7 @@
from hypothesis import event, given
from hypothesis.strategies import datetimes
from icalendar import Parameters, vCalAddress, vRecur, vText
from packaging import version

from khal.khalendar.event import (AllDayEvent, Event, FloatingEvent,
LocalizedEvent, create_timezone)
Expand Down Expand Up @@ -341,12 +342,12 @@ def test_event_dt_long():
'09.04.2014 09:30-12.04.2014 10:30 An Event\x1b[0m'


def test_event_no_dst(pytz_version):
def test_event_no_dst():
"""test the creation of a corect VTIMEZONE for timezones with no dst"""
event_no_dst = _get_text('event_no_dst')
cal_no_dst = _get_text('cal_no_dst')
event = Event.fromString(event_no_dst, calendar='foobar', locale=LOCALE_BOGOTA)
if pytz_version > (2017, 1):
if version.parse(pytz.__version__) > version.Version('2017.1'):
cal_no_dst = cal_no_dst.replace(
'TZNAME:COT',
'RDATE:20380118T221407\r\nTZNAME:-05'
Expand Down
5 changes: 3 additions & 2 deletions tests/vtimezone_test.py
@@ -1,6 +1,7 @@
import datetime as dt

import pytz
from packaging import version

from khal.khalendar.event import create_timezone

Expand Down Expand Up @@ -63,7 +64,7 @@ def test_berlin_rdate():
assert vberlin_dst in vberlin


def test_bogota(pytz_version):
def test_bogota():
vbogota = [b'BEGIN:VTIMEZONE',
b'TZID:America/Bogota',
b'BEGIN:STANDARD',
Expand All @@ -74,7 +75,7 @@ def test_bogota(pytz_version):
b'END:STANDARD',
b'END:VTIMEZONE',
b'']
if pytz_version > (2017, 1):
if version.parse(pytz.__version__) > version.Version('2017.1'):
vbogota[4] = b'TZNAME:-05'
vbogota.insert(4, b'RDATE:20380118T221407')

Expand Down

0 comments on commit f6c9b8a

Please sign in to comment.