From db6c6e1a55418faec3ef5c840153ed5c1a9faddd Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sat, 10 Oct 2015 13:10:11 +0300 Subject: [PATCH] xmltok: Add test. --- xmltok/test.xml | 13 +++++++++++++ xmltok/test_xmltok.py | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 xmltok/test.xml create mode 100644 xmltok/test_xmltok.py diff --git a/xmltok/test.xml b/xmltok/test.xml new file mode 100644 index 00000000..1c3607f1 --- /dev/null +++ b/xmltok/test.xml @@ -0,0 +1,13 @@ + + + + + foo bar + baz + + + + diff --git a/xmltok/test_xmltok.py b/xmltok/test_xmltok.py new file mode 100644 index 00000000..05953e90 --- /dev/null +++ b/xmltok/test_xmltok.py @@ -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)