diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2015-02-27 16:34:40 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2015-02-27 16:34:40 +0100 |
commit | 4a1c2e9ff3c99247ec1da2707b29e3bb336d641d (patch) | |
tree | 6c91256c0af277a6f7f544d622383866eeb22b76 /src/lxml/tests/test_etree.py | |
parent | 453f90fe237fee16a41226d8bc94082fcd738fa4 (diff) | |
download | python-lxml-4a1c2e9ff3c99247ec1da2707b29e3bb336d641d.tar.gz |
implement a way to move selected namespace declarations to the top during cleanup
Diffstat (limited to 'src/lxml/tests/test_etree.py')
-rw-r--r-- | src/lxml/tests/test_etree.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lxml/tests/test_etree.py b/src/lxml/tests/test_etree.py index 540134ff..f995d16a 100644 --- a/src/lxml/tests/test_etree.py +++ b/src/lxml/tests/test_etree.py @@ -2663,6 +2663,20 @@ class ETreeOnlyTestCase(HelperTestCase): b'<n64:x/>' + b'</a>'*100 + b'</root>', self.etree.tostring(root)) + def test_namespace_cleanup_deep_to_top(self): + xml = ('<root>' + + ''.join('<a xmlns:n{n}="NS{n}">'.format(n=i) for i in range(100)) + + '<n64:x xmlns:a="A" a:attr="X"/>' + + '</a>'*100 + + '</root>').encode('utf8') + root = self.etree.fromstring(xml) + self.assertEqual(xml, self.etree.tostring(root)) + self.etree.cleanup_namespaces(root, top_nsmap={'n64': 'NS64'}) + self.assertEqual( + b'<root xmlns:n64="NS64">' + b'<a>'*100 + + b'<n64:x xmlns:a="A" a:attr="X"/>' + b'</a>'*100 + b'</root>', + self.etree.tostring(root)) + def test_element_nsmap(self): etree = self.etree |