diff --git a/src/icalendar/prop.py b/src/icalendar/prop.py index e2d6ef60..0a4c1b0e 100644 --- a/src/icalendar/prop.py +++ b/src/icalendar/prop.py @@ -256,6 +256,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' ) +