FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-9883: writexml on a DocumentFragment acts on children by arp11 · Pull Request #1745 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 11 additions & 0 deletions Lib/test/test_minidom.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import copy
import pickle
from io import StringIO
from test.support import findfile
import unittest

Expand Down Expand Up @@ -188,6 +189,14 @@ def testReplaceChildFragment(self):
frag.unlink()
dom.unlink()

def testWriteXMLChildFragment(self):
dom, orig, c1, c2, c3, frag = self._create_fragment_test_nodes()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You could delete unused vars by using dom, *_, frag = ....

written = StringIO()
frag.writexml(writer=written, indent=' ', addindent='-', newl=':')
self.assertEquals(written.getvalue(), ' foo: bar: bat:')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Use self.assertEqual() (without the trailing s).

frag.unlink()
dom.unlink()

def testLegalChildren(self):
dom = Document()
elem = dom.createElement('element')
Expand Down Expand Up @@ -235,8 +244,10 @@ def testNonZero(self):

def testUnlink(self):
dom = parse(tstfile)
self.confirm(isinstance(dom, Document))
self.assertTrue(dom.childNodes)
dom.unlink()
self.confirm(isinstance(dom, Document))
self.assertFalse(dom.childNodes)

def testContext(self):
Expand Down
3 changes: 3 additions & 0 deletions Lib/xml/dom/minidom.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ class DocumentFragment(Node):
def __init__(self):
self.childNodes = NodeList()

def writexml(self, writer, indent="", addindent="", newl=""):
for node in self.childNodes:
node.writexml(writer, indent, addindent, newl)

class Attr(Node):
__slots__=('_name', '_value', 'namespaceURI',
Expand Down

Back | FazBrowse Home | New Git URL