xmltok: Add test.

pull/46/head
Paul Sokolovsky 2015-10-10 13:10:11 +03:00
rodzic 8e19a487c5
commit db6c6e1a55
2 zmienionych plików z 34 dodań i 0 usunięć

13
xmltok/test.xml 100644
Wyświetl plik

@ -0,0 +1,13 @@
<?xml version="1.0"?>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:GetConnectionTypeInfo
xmlns:u="urn:schemas-upnp-org:service:WANIPConnection:1">
foo bar
baz
</u:GetConnectionTypeInfo>
</s:Body>
</s:Envelope>

Wyświetl plik

@ -0,0 +1,21 @@
import xmltok
expected = [
('PI', 'xml'),
('ATTR', ('', 'version'), '1.0'),
('START_TAG', ('s', 'Envelope')),
('ATTR', ('xmlns', 's'), 'http://schemas.xmlsoap.org/soap/envelope/'),
('ATTR', ('s', 'encodingStyle'), 'http://schemas.xmlsoap.org/soap/encoding/'),
('START_TAG', ('s', 'Body')),
('START_TAG', ('u', 'GetConnectionTypeInfo')),
('ATTR', ('xmlns', 'u'), 'urn:schemas-upnp-org:service:WANIPConnection:1'),
('TEXT', 'foo bar\n baz\n \n'),
('END_TAG', ('u', 'GetConnectionTypeInfo')),
('END_TAG', ('s', 'Body')),
('END_TAG', ('s', 'Envelope')),
]
ex = iter(expected)
for i in xmltok.tokenize(open("test.xml")):
#print(i)
assert i == next(ex)