From 84e2b1acb030e1f59bc65e59c3eb958aba9e1d3b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 30 Jun 2013 09:41:21 -0400 Subject: [PATCH] test/data/geohash.ics: Pull out geohashing example from Feed doctest This makes it easier to reuse the test data in other locations. Also escape commas in the data. From RFC 5545, section 3.3.11. Text: The "TEXT" property values may also contain special characters that are used to signify delimiters, such as a COMMA character for lists of values or a SEMICOLON character for structured values. In order to support the inclusion of these special characters in "TEXT" property values, they MUST be escaped with a BACKSLASH character. --- pycalendar/feed.py | 29 +++++++++-------------------- test/data/geohash.ics | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 test/data/geohash.ics diff --git a/pycalendar/feed.py b/pycalendar/feed.py index 1accb08..b4a90c1 100644 --- a/pycalendar/feed.py +++ b/pycalendar/feed.py @@ -11,24 +11,13 @@ class Feed (object): We can't fetch this dummy url, so load the content by hand. - >>> f.content = '\r\n'.join([ - ... 'BEGIN:VCALENDAR', - ... 'VERSION:2.0', - ... 'PRODID:-//Example Calendar//NONSGML v1.0//EN', - ... 'BEGIN:VEVENT', - ... 'UID:2013-06-30@geohash.invalid', - ... 'DTSTAMP:2013-06-30T00:00:00Z', - ... 'DTSTART;VALUE=DATE:20130630', - ... 'DTEND;VALUE=DATE:20130701', - ... 'SUMMARY:XKCD geohashing, Boston graticule', - ... 'URL:http://xkcd.com/426/', - ... 'LOCATION:Snow Hill, Dover, Massachusetts', - ... 'GEO:42.226663,-71.28676', - ... 'END:VEVENT', - ... 'END:VCALENDAR', - ... '', - ... ]) - >>> print(f) + >>> import os + >>> root_dir = os.curdir + >>> data_file = os.path.join(os.curdir, 'test', 'data', 'geohash.ics') + >>> with open(data_file, 'r') as data: + ... f.content = data.read().replace('\n', data.newlines) + ... assert data.newlines == '\r\n', data.newlines + >>> print(f) # doctest: +REPORT_UDIFF BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Example Calendar//NONSGML v1.0//EN @@ -37,9 +26,9 @@ class Feed (object): DTSTAMP:2013-06-30T00:00:00Z DTSTART;VALUE=DATE:20130630 DTEND;VALUE=DATE:20130701 - SUMMARY:XKCD geohashing, Boston graticule + SUMMARY:XKCD geohashing\, Boston graticule URL:http://xkcd.com/426/ - LOCATION:Snow Hill, Dover, Massachusetts + LOCATION:Snow Hill\, Dover\, Massachusetts GEO:42.226663,-71.28676 END:VEVENT END:VCALENDAR diff --git a/test/data/geohash.ics b/test/data/geohash.ics new file mode 100644 index 0000000..129150d --- /dev/null +++ b/test/data/geohash.ics @@ -0,0 +1,14 @@ +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Example Calendar//NONSGML v1.0//EN +BEGIN:VEVENT +UID:2013-06-30@geohash.invalid +DTSTAMP:2013-06-30T00:00:00Z +DTSTART;VALUE=DATE:20130630 +DTEND;VALUE=DATE:20130701 +SUMMARY:XKCD geohashing\, Boston graticule +URL:http://xkcd.com/426/ +LOCATION:Snow Hill\, Dover\, Massachusetts +GEO:42.226663,-71.28676 +END:VEVENT +END:VCALENDAR -- 2.26.2