From 4dc2ea2b3a034d8596ea39c09d9a0644b8677965 Mon Sep 17 00:00:00 2001 From: rahul50502a Date: Sun, 30 Jun 2024 16:11:54 +0530 Subject: [PATCH] SOlve issue #610 --- src/icalendar/prop.py | 3 +++ src/icalendar/tests/prop/test_unit.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/icalendar/prop.py b/src/icalendar/prop.py index d61ef547..629a037a 100644 --- a/src/icalendar/prop.py +++ b/src/icalendar/prop.py @@ -233,6 +233,9 @@ def __init__(self, c_list): self.cats = [vText(c) for c in c_list] self.params = Parameters() + def __iter__(self): + return iter(vCategory.from_ical(self.to_ical())) + def to_ical(self): return b",".join([c.to_ical() for c in self.cats]) diff --git a/src/icalendar/tests/prop/test_unit.py b/src/icalendar/tests/prop/test_unit.py index cd34ca5c..57a6ed62 100644 --- a/src/icalendar/tests/prop/test_unit.py +++ b/src/icalendar/tests/prop/test_unit.py @@ -336,6 +336,9 @@ def test_prop_vCategory(self): self.assertEqual(v_cat.to_ical(), b'cat 1,cat 2,cat 3') self.assertEqual(vCategory.from_ical(v_cat.to_ical()), catz) + c = vCategory(vCategory.from_ical("APPOINTMENT,EDUCATION")) + cats = list(c) + assert cats == ["APPOINTMENT", "EDUCATION"] def test_prop_TypesFactory(self): from icalendar.prop import TypesFactory @@ -365,3 +368,4 @@ def test_prop_TypesFactory(self): factory.from_ical('cn', b'Rasmussen\\, Max M\xc3\xb8ller'), 'Rasmussen, Max M\xf8ller' ) +