Skip to content

Commit

Permalink
fix #322
Browse files Browse the repository at this point in the history
  • Loading branch information
jacadzaca committed Sep 30, 2023
1 parent 0fdbdfb commit 0e06a37
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ New features:

Bug fixes:

- ...
- CATEGORIES field now accepts strings properly
Ref: #322
[jacadzaca]

5.0.10 (unreleased)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/icalendar/prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def from_ical(ical, timezone=None):
class vCategory:

def __init__(self, c_list):
if not hasattr(c_list, '__iter__'):
if not hasattr(c_list, '__iter__') or isinstance(c_list, str):
c_list = [c_list]
self.cats = [vText(c) for c in c_list]

Expand Down
6 changes: 6 additions & 0 deletions src/icalendar/tests/calendars/issue_322_expected_calendar.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BEGIN:VCALENDAR
BEGIN:VEVENT
SUMMARY:Event with bare string as argument for categories
CATEGORIES:Lecture
END:VEVENT
END:VCALENDAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from icalendar import Calendar, Event


def test_issue_322_single_string_split_into_multiple_categories(calendars):
calendar = Calendar()
event = Event()
event.add('summary', 'Event with bare string as argument for categories')
event.add('categories', "Lecture")
calendar.add_component(event)
assert calendar.to_ical() == calendars.issue_322_expected_calendar.raw_ics

0 comments on commit 0e06a37

Please sign in to comment.