File: test_utils.py

package info (click to toggle)
qm 1.1.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 8,628 kB
  • ctags: 10,249
  • sloc: python: 41,482; ansic: 20,611; xml: 12,837; sh: 485; makefile: 226
file content (29 lines) | stat: -rw-r--r-- 933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Test the modules in the utils/ subpackage
# FIXME: escape is now in xml.sax.saxutils, need to move testcase as well

from xml.utils import *
from xml.sax.saxutils import escape

print 'Testing utils.escape'
print 'These pairs of strings should all be identical'

v1, v2 = escape('&<>'), '&amp;&lt;&gt;'
print v1 == v2, repr(v1), repr(v2)
v1, v2 = escape('foo&amp;bar'), 'foo&amp;amp;bar'
print v1 == v2, repr(v1), repr(v2)
v1, v2 = escape('< test > &', {'test': '&myentity;'}), '&lt; &myentity; &gt; &amp;'
print v1 == v2, repr(v1), repr(v2)
v1, v2 = escape('&\'"<>', {'"': '&quot;', "'": '&apos;'}), '&amp;&apos;&quot;&lt;&gt;'
print v1 == v2, repr(v1), repr(v2)

# Test the iso8601 module

for dt in ['1998', '1998-06', '1998-06-13', 
           '1998-06-13T14:12Z',
           '1998-06-13T14:12:30Z', 
           '1998-06-13T14:12:30.2Z'
           ]:
    date = iso8601.parse( dt )
    print iso8601.tostring( date )