Convert .py files to .txt files for examples, using new doctest.py. Add

them to test_icalendar.py, so that they get picked up by the testrunner.
pull/6/head
Martijn Faassen 2005-03-23 14:27:37 +00:00
rodzic c1e63a1cb2
commit 6c35b6fae3
5 zmienionych plików z 18 dodań i 31 usunięć

Wyświetl plik

@ -1,5 +1,4 @@
# -*- coding: latin-1 -*-
"""
iCalendar package
=================
@ -91,10 +90,10 @@ You can generate a string for a file with the as_string() method. (Calling
str(cal) does the same):
>>> cal.as_string()
'BEGIN:VCALENDAR\\r\\nDTSTART:20050404T080000\\r\\nSUMMARY:Python meeting about calendaring\\r\\nEND:VCALENDAR\\r\\n'
'BEGIN:VCALENDAR\r\nDTSTART:20050404T080000\r\nSUMMARY:Python meeting about calendaring\r\nEND:VCALENDAR\r\n'
>>> str(cal)
'BEGIN:VCALENDAR\\r\\nDTSTART:20050404T080000\\r\\nSUMMARY:Python meeting about calendaring\\r\\nEND:VCALENDAR\\r\\n'
'BEGIN:VCALENDAR\r\nDTSTART:20050404T080000\r\nSUMMARY:Python meeting about calendaring\r\nEND:VCALENDAR\r\n'
in the calendar examples below the as_string() is implied. The rendered view is
easier to read:
@ -272,7 +271,9 @@ that can be loaded into the Mozilla calendar
>>> cal.add_component(event)
Write to disc
>>> f = open('example.ics', 'wb')
>>> import os
>>> directory = os.path.dirname(__file__)
>>> f = open(os.path.join(directory, 'example.ics'), 'wb')
>>> f.write(cal.as_string())
>>> f.close()
@ -298,10 +299,3 @@ And that generates this file.
--
Enjoy, Max M, maxm@mxm.dk
"""
if __name__ == "__main__":
import os.path, doctest, example
# import and test this file
doctest.testmod(example)

Wyświetl plik

@ -1,10 +1,12 @@
# -*- coding: latin-1 -*-
"""
An example from the RFC 2445 spec.
>>> from iCalendar import Calendar
>>> cal = Calendar.from_string(open('groupscheduled.ics','rb').read())
>>> import os
>>> directory = os.path.dirname(__file__)
>>> cal = Calendar.from_string(
... open(os.path.join(directory, 'groupscheduled.ics'),'rb').read())
>>> cal
VCALENDAR({'VERSION': '2.0', 'PRODID': '-//RDU Software//NONSGML HandCal//EN'})
@ -19,10 +21,3 @@ An example from the RFC 2445 spec.
>>> std = tz.walk('STANDARD')[0]
>>> std.decoded('TZOFFSETFROM')
datetime.timedelta(-1, 72000)
"""
if __name__ == "__main__":
import os.path, doctest, groupscheduled
# import and test this file
doctest.testmod(groupscheduled)

Wyświetl plik

@ -1,10 +1,12 @@
# -*- coding: latin-1 -*-
"""
A small example
>>> from iCalendar import Calendar
>>> cal = Calendar.from_string(open('test.ics','rb').read())
>>> import os
>>> directory = os.path.dirname(__file__)
>>> cal = Calendar.from_string(
... open(os.path.join(directory, 'small.ics'),'rb').read())
>>> cal
VCALENDAR({'VERSION': '2.0', 'METHOD': 'Request', 'PRODID': '-//My product//mxm.dk/'})
@ -26,10 +28,3 @@ A small example
>>> first_event['summary']
'A second event'
"""
if __name__ == "__main__":
import os.path, doctest, test
# import and test this file
doctest.testmod(test)

Wyświetl plik

@ -1,14 +1,17 @@
import unittest, doctest
import unittest, doctest, os
from iCalendar import iCalendar, CaselessDict, ContentlinesParser
from iCalendar import PropertyValues, tools
def test_suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(CaselessDict))
suite.addTest(doctest.DocTestSuite(ContentlinesParser))
suite.addTest(doctest.DocTestSuite(PropertyValues))
suite.addTest(doctest.DocTestSuite(iCalendar))
doc_dir = '../../../doc'
for docfile in ['example.txt', 'groupscheduled.txt', 'small.txt']:
suite.addTest(doctest.DocFileSuite(os.path.join(doc_dir, docfile)))
# only has a disabled doctest
# suite.addTest(doctest.DocTestSuite(tools))
return suite