Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Feb 17, 2016
1 parent 23027d3 commit 0292a70
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions streamingxmlwriter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@
<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://mynamespace.org/"><e a="1"></e></root>
Another example with namespace change:
>>> s = BytesIO()
>>> with from_stream(s) as writer:
... with writer.element("root"):
... writer.start_namespace(None, "urn:ns1")
... with writer.element("e"):
... pass
... writer.end_namespace(None)
... writer.start_namespace(None, "urn:ns2")
... with writer.element("f"):
... pass
>>> bprint(s.getvalue())
<?xml version="1.0" encoding="utf-8"?>
<root><e xmlns="urn:ns1"></e><f xmlns="urn:ns2"></f></root>
Example with explicit closing (more verbose but could be useful too):
>>> s = BytesIO()
Expand Down Expand Up @@ -245,6 +261,3 @@ def from_sax_handler(handler):
return _StreamingXMLWriter(handler)


if __name__ == '__main__':
import doctest
doctest.testmod()

0 comments on commit 0292a70

Please sign in to comment.