mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #22777: Test pickling with all protocols.
This commit is contained in:
parent
79b81738ef
commit
bad1257c96
30 changed files with 701 additions and 621 deletions
|
@ -1468,43 +1468,44 @@ class MinidomTest(unittest.TestCase):
|
|||
" <!ENTITY ent SYSTEM 'http://xml.python.org/entity'>\n"
|
||||
"]><doc attr='value'> text\n"
|
||||
"<?pi sample?> <!-- comment --> <e/> </doc>")
|
||||
s = pickle.dumps(doc)
|
||||
doc2 = pickle.loads(s)
|
||||
stack = [(doc, doc2)]
|
||||
while stack:
|
||||
n1, n2 = stack.pop()
|
||||
self.confirm(n1.nodeType == n2.nodeType
|
||||
and len(n1.childNodes) == len(n2.childNodes)
|
||||
and n1.nodeName == n2.nodeName
|
||||
and not n1.isSameNode(n2)
|
||||
and not n2.isSameNode(n1))
|
||||
if n1.nodeType == Node.DOCUMENT_TYPE_NODE:
|
||||
len(n1.entities)
|
||||
len(n2.entities)
|
||||
len(n1.notations)
|
||||
len(n2.notations)
|
||||
self.confirm(len(n1.entities) == len(n2.entities)
|
||||
and len(n1.notations) == len(n2.notations))
|
||||
for i in range(len(n1.notations)):
|
||||
# XXX this loop body doesn't seem to be executed?
|
||||
no1 = n1.notations.item(i)
|
||||
no2 = n1.notations.item(i)
|
||||
self.confirm(no1.name == no2.name
|
||||
and no1.publicId == no2.publicId
|
||||
and no1.systemId == no2.systemId)
|
||||
stack.append((no1, no2))
|
||||
for i in range(len(n1.entities)):
|
||||
e1 = n1.entities.item(i)
|
||||
e2 = n2.entities.item(i)
|
||||
self.confirm(e1.notationName == e2.notationName
|
||||
and e1.publicId == e2.publicId
|
||||
and e1.systemId == e2.systemId)
|
||||
stack.append((e1, e2))
|
||||
if n1.nodeType != Node.DOCUMENT_NODE:
|
||||
self.confirm(n1.ownerDocument.isSameNode(doc)
|
||||
and n2.ownerDocument.isSameNode(doc2))
|
||||
for i in range(len(n1.childNodes)):
|
||||
stack.append((n1.childNodes[i], n2.childNodes[i]))
|
||||
for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
|
||||
s = pickle.dumps(doc, proto)
|
||||
doc2 = pickle.loads(s)
|
||||
stack = [(doc, doc2)]
|
||||
while stack:
|
||||
n1, n2 = stack.pop()
|
||||
self.confirm(n1.nodeType == n2.nodeType
|
||||
and len(n1.childNodes) == len(n2.childNodes)
|
||||
and n1.nodeName == n2.nodeName
|
||||
and not n1.isSameNode(n2)
|
||||
and not n2.isSameNode(n1))
|
||||
if n1.nodeType == Node.DOCUMENT_TYPE_NODE:
|
||||
len(n1.entities)
|
||||
len(n2.entities)
|
||||
len(n1.notations)
|
||||
len(n2.notations)
|
||||
self.confirm(len(n1.entities) == len(n2.entities)
|
||||
and len(n1.notations) == len(n2.notations))
|
||||
for i in range(len(n1.notations)):
|
||||
# XXX this loop body doesn't seem to be executed?
|
||||
no1 = n1.notations.item(i)
|
||||
no2 = n1.notations.item(i)
|
||||
self.confirm(no1.name == no2.name
|
||||
and no1.publicId == no2.publicId
|
||||
and no1.systemId == no2.systemId)
|
||||
stack.append((no1, no2))
|
||||
for i in range(len(n1.entities)):
|
||||
e1 = n1.entities.item(i)
|
||||
e2 = n2.entities.item(i)
|
||||
self.confirm(e1.notationName == e2.notationName
|
||||
and e1.publicId == e2.publicId
|
||||
and e1.systemId == e2.systemId)
|
||||
stack.append((e1, e2))
|
||||
if n1.nodeType != Node.DOCUMENT_NODE:
|
||||
self.confirm(n1.ownerDocument.isSameNode(doc)
|
||||
and n2.ownerDocument.isSameNode(doc2))
|
||||
for i in range(len(n1.childNodes)):
|
||||
stack.append((n1.childNodes[i], n2.childNodes[i]))
|
||||
|
||||
def testSerializeCommentNodeWithDoubleHyphen(self):
|
||||
doc = create_doc_without_doctype()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue