vContent

tests/test_reader.py

54:e2841274e1fb
2014-10-09 Paul Boddie Added convenience and support functions for handling iCalendar rule values.
     1 #!/usr/bin/env python     2      3 import vContent     4 import StringIO     5      6 s = StringIO.StringIO("""PROP:p1=v1;p2     7  =v2;p21;p3=v3;"p4"="v4";"p5=v5     8  ;p5=v5":"hello     9   world\\nend test"    10 """)    11     12 r = vContent.Reader(s)    13 line = r.get_content_line()    14 print repr(line.text)    15     16 data = line.search(line.SEPARATORS)    17 print data    18 assert data == ("PROP", ":")    19 data = line.search(line.SEPARATORS_PLUS_EQUALS)    20 print data    21 assert data == ("p1", "=")    22 data = line.search(line.SEPARATORS)    23 print data    24 assert data == ("v1", ";")    25 data = line.search(line.SEPARATORS_PLUS_EQUALS)    26 print data    27 assert data == ("p2", "=")    28 data = line.search(line.SEPARATORS)    29 print data    30 assert data == ("v2", ";")    31 data = line.search(line.SEPARATORS_PLUS_EQUALS)    32 print data    33 assert data == ("p21", ";")    34 data = line.search(line.SEPARATORS_PLUS_EQUALS)    35 print data    36 assert data == ("p3", "=")    37 data = line.search(line.SEPARATORS)    38 print data    39 assert data == ("v3", ";")    40 data = line.search(line.SEPARATORS_PLUS_EQUALS)    41 print data    42 assert data == ('"p4"', "=")    43 data = line.search(line.SEPARATORS)    44 print data    45 assert data == ('"v4"', ";")    46 data = line.search(line.SEPARATORS_PLUS_EQUALS)    47 print data    48 assert data == ('"p5=v5;p5=v5"', ":")    49 data = line.get_remaining()    50 print repr(data)    51 assert data == '"hello world\\nend test"'    52     53 # vim: tabstop=4 expandtab shiftwidth=4