vContent

tests/test_card_stream.py

68:fdf18b11959b
2015-10-13 Paul Boddie Fixed encoding of None values produced by vCalendar parsing.
     1 #!/usr/bin/env python     2      3 "Perform a round trip with an input card, comparing the result to the original."     4      5 import codecs, vContent, os     6      7 this_dir = os.path.split(__file__)[0]     8 f = codecs.open(os.path.join(this_dir, "test.vcf"), encoding="utf-8")     9 out = codecs.open("tmp.vcf", "w", encoding="utf-8")    10 try:    11     doc = vContent.iterparse(f)    12     w = vContent.iterwrite(out)    13     for name, parameters, value in doc:    14         print "%r, %r, %r" % (name, parameters, value)    15         w.write(name, parameters, value)    16 finally:    17     out.close()    18     f.close()    19     20 print "--------"    21     22 f = codecs.open(os.path.join(this_dir, "test.vcf"), encoding="utf-8")    23 f2 = codecs.open("tmp.vcf", encoding="utf-8")    24 try:    25     doc = vContent.iterparse(f)    26     doc2 = vContent.iterparse(f2)    27     for (name, parameters, value), (name2, parameters2, value2) in zip(doc, doc2):    28         print "%r, %r, %r" % (name, parameters, value)    29         print "%r, %r, %r" % (name2, parameters2, value2)    30         assert name == name2    31         assert parameters == parameters2    32         assert value == value2    33 finally:    34     f2.close()    35     f.close()    36     37 # vim: tabstop=4 expandtab shiftwidth=4