Fix ical tests

This commit is contained in:
Ludovic Stephan 2020-05-12 00:47:48 +02:00
parent 50266f2466
commit 9b0440429c

View file

@ -101,8 +101,8 @@ class ICalMixin:
def _find_event(self, ev, l): def _find_event(self, ev, l):
for i, elt in enumerate(l): for i, elt in enumerate(l):
if self._test_event_equal(ev, elt): if self._test_event_equal(ev, elt):
return elt, i return i
return False, -1 return None
def assertCalEqual(self, ical_content, expected): def assertCalEqual(self, ical_content, expected):
remaining = expected.copy() remaining = expected.copy()
@ -111,12 +111,15 @@ class ICalMixin:
cal = icalendar.Calendar.from_ical(ical_content) cal = icalendar.Calendar.from_ical(ical_content)
for ev in cal.walk("vevent"): for ev in cal.walk("vevent"):
found, i_found = self._find_event(ev, remaining) i_found = self._find_event(ev, remaining)
if found: if i_found is not None:
remaining.pop(i_found) remaining.pop(i_found)
else: else:
unexpected.append(ev) unexpected.append(ev)
self.assertListEqual(remaining, [])
self.assertListEqual(unexpected, [])
class TestCaseMixin: class TestCaseMixin:
def assertForbidden(self, response): def assertForbidden(self, response):