summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-07-27 14:58:14 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-07-27 15:03:52 +0200
commit90e98240c854fb8ee491919794d65fa431e78c01 (patch)
treede85ed3679218b655137d7e87674b19349926432 /tests
parentdc4c2f9d2db5563ad482a09d04aeeab6972c53ac (diff)
downloadgobject-introspection-90e98240c854fb8ee491919794d65fa431e78c01.tar.gz
xmlwriter: move collect_attributes() back to a Python implementation
This reverts f345916405d94829696985 and related. The commit states that both versions are about the same in performance, but the C version is more code and harder to maintain. It also states that the behaviour re invalid control characters is better with the C version which produces entities. But those make any Python xml parser fail, which given that most of our tooling is Python, doesn't seem better to me, see #135.
Diffstat (limited to 'tests')
-rw-r--r--tests/scanner/test_xmlwriter.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/scanner/test_xmlwriter.py b/tests/scanner/test_xmlwriter.py
index e24923bd..c6748c00 100644
--- a/tests/scanner/test_xmlwriter.py
+++ b/tests/scanner/test_xmlwriter.py
@@ -40,10 +40,16 @@ class TestXMLWriter(unittest.TestCase):
self.assertEqual(res, '<tag attr="utf8"/>')
res = build_xml_tag('tag', [('attr', 'foo\nbar')])
- self.assertEqual(res, '<tag attr="foo\nbar"/>')
+ self.assertEqual(res, '<tag attr="foo&#10;bar"/>')
+
+ res = build_xml_tag('tag', [('attr', 'foo\tbar')])
+ self.assertEqual(res, '<tag attr="foo&#9;bar"/>')
res = build_xml_tag('tag', [('attr', '\004')])
- self.assertEqual(res, '<tag attr="&#x4;"/>')
+ self.assertEqual(res, '<tag attr="\x04"/>')
+
+ res = build_xml_tag('tag', [('attr', 'limba1\t\034')])
+ self.assertEqual(res, '<tag attr="limba1&#9;\034"/>')
res = build_xml_tag('tag', [('attr', '')])
self.assertEqual(res, '<tag attr=""/>')
@@ -57,6 +63,9 @@ class TestXMLWriter(unittest.TestCase):
res = build_xml_tag('tag', [('a', 'b'), ('c', 'd')])
self.assertEqual(res, '<tag a="b" c="d"/>')
+ res = build_xml_tag('tag', [('foo', None), ('bar', 'quux')])
+ self.assertEqual(res, '<tag bar="quux"/>')
+
def test_build_xml_tag_data(self):
res = build_xml_tag('tag', [], b'foo')
self.assertEqual(res, '<tag>foo</tag>')