diff --git a/src/icalendar/cal.py b/src/icalendar/cal.py index b718765b..40889717 100644 --- a/src/icalendar/cal.py +++ b/src/icalendar/cal.py @@ -437,6 +437,9 @@ def __repr__(self): return f"{self.name or type(self).__name__}({dict(self)}{', ' + subs if subs else ''})" def __eq__(self, other): + if not len(self.subcomponents) == len(other.subcomponents): + return False + properties_equal = super().__eq__(other) if not properties_equal: return False diff --git a/src/icalendar/tests/calendars/issue_526_calendar_with_event_subset.ics b/src/icalendar/tests/calendars/issue_526_calendar_with_event_subset.ics new file mode 100644 index 00000000..4624f2f5 --- /dev/null +++ b/src/icalendar/tests/calendars/issue_526_calendar_with_event_subset.ics @@ -0,0 +1,11 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:icalendar-2023 +BEGIN:VEVENT +UID:1 +SUMMARY: Some event ':' +DTSTART;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T160000 +DTEND;TZID="Western/Central Europe";VALUE=DATE-TIME:20211101T163000 +DTSTAMP:20211004T150245Z +END:VEVENT +END:VCALENDAR diff --git a/src/icalendar/tests/test_unit_cal.py b/src/icalendar/tests/test_unit_cal.py index e3a9ce3a..410abce5 100644 --- a/src/icalendar/tests/test_unit_cal.py +++ b/src/icalendar/tests/test_unit_cal.py @@ -469,6 +469,7 @@ def test_cal_strict_parsing(self): 'issue_178_custom_component_inside_other', 'issue_526_calendar_with_events', 'issue_526_calendar_with_different_events', + 'issue_526_calendar_with_event_subset', ], repeat=2) ) def test_comparing_calendars(calendars, calendar, other_calendar):