test/data/geohash.ics: Pull out geohashing example from Feed doctest
authorW. Trevor King <wking@tremily.us>
Sun, 30 Jun 2013 13:41:21 +0000 (09:41 -0400)
committerW. Trevor King <wking@tremily.us>
Sun, 30 Jun 2013 16:26:16 +0000 (12:26 -0400)
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
test/data/geohash.ics [new file with mode: 0644]

index 1accb0840b8381b51a54a9310652ad44687f02d2..b4a90c1f97b1828f53aa0b287e6d14e3e51e6a13 100644 (file)
@@ -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 (file)
index 0000000..129150d
--- /dev/null
@@ -0,0 +1,14 @@
+BEGIN:VCALENDAR\r
+VERSION:2.0\r
+PRODID:-//Example Calendar//NONSGML v1.0//EN\r
+BEGIN:VEVENT\r
+UID:2013-06-30@geohash.invalid\r
+DTSTAMP:2013-06-30T00:00:00Z\r
+DTSTART;VALUE=DATE:20130630\r
+DTEND;VALUE=DATE:20130701\r
+SUMMARY:XKCD geohashing\, Boston graticule\r
+URL:http://xkcd.com/426/\r
+LOCATION:Snow Hill\, Dover\, Massachusetts\r
+GEO:42.226663,-71.28676\r
+END:VEVENT\r
+END:VCALENDAR\r