Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
161194a5
Commit
161194a5
authored
Apr 10, 2013
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Plain Diff
#12820: merge with 3.3.
parents
3f5ffbee
cd514cf1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
0 deletions
+109
-0
Lib/test/test_xml_dom_minicompat.py
Lib/test/test_xml_dom_minicompat.py
+101
-0
Lib/test/xmltests.py
Lib/test/xmltests.py
+1
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+6
-0
No files found.
Lib/test/test_xml_dom_minicompat.py
0 → 100644
View file @
161194a5
# Tests for xml.dom.minicompat
import
pickle
import
unittest
import
xml.dom
from
xml.dom.minicompat
import
*
class
EmptyNodeListTestCase
(
unittest
.
TestCase
):
"""Tests for the EmptyNodeList class."""
def
test_emptynodelist_item
(
self
):
# Test item access on an EmptyNodeList.
node_list
=
EmptyNodeList
()
self
.
assertIsNone
(
node_list
.
item
(
0
))
self
.
assertIsNone
(
node_list
.
item
(
-
1
))
# invalid item
with
self
.
assertRaises
(
IndexError
):
node_list
[
0
]
with
self
.
assertRaises
(
IndexError
):
node_list
[
-
1
]
def
test_emptynodelist_length
(
self
):
node_list
=
EmptyNodeList
()
# Reading
self
.
assertEqual
(
node_list
.
length
,
0
)
# Writing
with
self
.
assertRaises
(
xml
.
dom
.
NoModificationAllowedErr
):
node_list
.
length
=
111
def
test_emptynodelist___add__
(
self
):
node_list
=
EmptyNodeList
()
+
NodeList
()
self
.
assertEqual
(
node_list
,
NodeList
())
def
test_emptynodelist___radd__
(
self
):
node_list
=
[
1
,
2
]
+
EmptyNodeList
()
self
.
assertEqual
(
node_list
,
[
1
,
2
])
class
NodeListTestCase
(
unittest
.
TestCase
):
"""Tests for the NodeList class."""
def
test_nodelist_item
(
self
):
# Test items access on a NodeList.
# First, use an empty NodeList.
node_list
=
NodeList
()
self
.
assertIsNone
(
node_list
.
item
(
0
))
self
.
assertIsNone
(
node_list
.
item
(
-
1
))
with
self
.
assertRaises
(
IndexError
):
node_list
[
0
]
with
self
.
assertRaises
(
IndexError
):
node_list
[
-
1
]
# Now, use a NodeList with items.
node_list
.
append
(
111
)
node_list
.
append
(
999
)
self
.
assertEqual
(
node_list
.
item
(
0
),
111
)
self
.
assertIsNone
(
node_list
.
item
(
-
1
))
# invalid item
self
.
assertEqual
(
node_list
[
0
],
111
)
self
.
assertEqual
(
node_list
[
-
1
],
999
)
def
test_nodelist_length
(
self
):
node_list
=
NodeList
([
1
,
2
])
# Reading
self
.
assertEqual
(
node_list
.
length
,
2
)
# Writing
with
self
.
assertRaises
(
xml
.
dom
.
NoModificationAllowedErr
):
node_list
.
length
=
111
def
test_nodelist___add__
(
self
):
node_list
=
NodeList
([
3
,
4
])
+
[
1
,
2
]
self
.
assertEqual
(
node_list
,
NodeList
([
3
,
4
,
1
,
2
]))
def
test_nodelist___radd__
(
self
):
node_list
=
[
1
,
2
]
+
NodeList
([
3
,
4
])
self
.
assertEqual
(
node_list
,
NodeList
([
1
,
2
,
3
,
4
]))
def
test_nodelist_pickle_roundtrip
(
self
):
# Test pickling and unpickling of a NodeList.
# Empty NodeList.
node_list
=
NodeList
()
pickled
=
pickle
.
dumps
(
node_list
)
unpickled
=
pickle
.
loads
(
pickled
)
self
.
assertEqual
(
unpickled
,
node_list
)
# Non-empty NodeList.
node_list
.
append
(
1
)
node_list
.
append
(
2
)
pickled
=
pickle
.
dumps
(
node_list
)
unpickled
=
pickle
.
loads
(
pickled
)
self
.
assertEqual
(
unpickled
,
node_list
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Lib/test/xmltests.py
View file @
161194a5
...
...
@@ -15,6 +15,7 @@ def runtest(name):
runtest
(
"test.test_minidom"
)
runtest
(
"test.test_pyexpat"
)
runtest
(
"test.test_sax"
)
runtest
(
"test.test_xml_dom_minicompat"
)
runtest
(
"test.test_xml_etree"
)
runtest
(
"test.test_xml_etree_c"
)
runtest
(
"test.test_xmlrpc"
)
Misc/ACKS
View file @
161194a5
...
...
@@ -240,6 +240,7 @@ Paul Colomiets
Christophe Combelles
Geremy Condra
Denver Coneybeare
Phil Connell
Juan José Conti
Matt Conway
David M. Cooke
...
...
Misc/NEWS
View file @
161194a5
...
...
@@ -67,6 +67,12 @@ Library
-
Issue
#
17032
:
The
"global"
in
the
"NameError: global name 'x' is not defined"
error
message
has
been
removed
.
Patch
by
Ram
Rachum
.
Tests
-----
-
Issue
#
12820
:
add
tests
for
the
xml
.
dom
.
minicompat
module
.
Patch
by
John
Chandler
and
Phil
Connell
.
What
's New in Python 3.3.1 release candidate 1?
===============================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment