Skip to content

bpo-36227: ElementTree.tostring() default_namespace argument#12225

Merged
scoder merged 15 commits into
python:masterfrom
codeape2:issue36227
Apr 14, 2019
Merged

bpo-36227: ElementTree.tostring() default_namespace argument#12225
scoder merged 15 commits into
python:masterfrom
codeape2:issue36227

Conversation

@codeape2

@codeape2 codeape2 commented Mar 7, 2019

Copy link
Copy Markdown
Contributor

@codeape2

codeape2 commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

This PR also fixes bpo-31256 (https://bugs.python.org/issue31256): xml.etree.ElementTree: add support for doctype in tostring method

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it would be nice to add similar tests for the write() method.

Comment thread Doc/library/xml.etree.elementtree.rst Outdated
Comment thread Doc/library/xml.etree.elementtree.rst
Comment thread Lib/xml/etree/ElementTree.py Outdated
Comment thread Lib/xml/etree/ElementTree.py Outdated
Comment thread Misc/NEWS.d/next/Library/2019-03-07-20-02-18.bpo-36227.i2Z1XR.rst Outdated
Comment thread Lib/test/test_xml_etree.py
Comment thread Lib/test/test_xml_etree.py Outdated
Comment thread Lib/test/test_xml_etree.py Outdated
elem = ET.XML('<body xmlns="http://effbot.org/ns"><tag/></body>')
self.assertEqual(
ET.tostringlist(elem, encoding='unicode')[0:2],
['<ns0:body', ' xmlns:ns0="http://effbot.org/ns"']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact splitting on chunks is an implementation detail. Test the value of b''.join(ET.tostringlist(elem, ...)) instead.

Co-Authored-By: codeape2 <bernt.brenna@gmail.com>
@codeape2

codeape2 commented Mar 8, 2019

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka I will look into your comments after the weekend.

@codeape2

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka I pushed commits addressing your comments.

I did not add any similar tests for .write() however, since .write() is in effect tested by tostring().

@serhiy-storchaka

Copy link
Copy Markdown
Member

LGTM. @scoder, could you please take a look?

@scoder
scoder merged commit ffca16e into python:master Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants