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
8911ca3d
Commit
8911ca3d
authored
Dec 16, 2005
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added encoding tests to ElementTree/cElementTree tests
parent
6d52b55c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
Lib/test/test_xml_etree.py
Lib/test/test_xml_etree.py
+16
-9
Lib/test/test_xml_etree_c.py
Lib/test/test_xml_etree_c.py
+15
-6
No files found.
Lib/test/test_xml_etree.py
View file @
8911ca3d
...
@@ -6,6 +6,8 @@ import doctest, sys
...
@@ -6,6 +6,8 @@ import doctest, sys
from
test
import
test_support
from
test
import
test_support
from
xmlcore.etree
import
ElementTree
as
ET
SAMPLE_XML
=
"""
SAMPLE_XML
=
"""
<body>
<body>
<tag>text</tag>
<tag>text</tag>
...
@@ -59,8 +61,6 @@ def interface():
...
@@ -59,8 +61,6 @@ def interface():
"""
"""
Test element tree interface.
Test element tree interface.
>>> from xmlcore.etree import ElementTree as ET
>>> element = ET.Element("tag", key="value")
>>> element = ET.Element("tag", key="value")
>>> tree = ET.ElementTree(element)
>>> tree = ET.ElementTree(element)
...
@@ -108,8 +108,6 @@ def find():
...
@@ -108,8 +108,6 @@ def find():
"""
"""
Test find methods (including xpath syntax).
Test find methods (including xpath syntax).
>>> from xmlcore.etree import ElementTree as ET
>>> elem = ET.XML(SAMPLE_XML)
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
>>> elem.find("tag").tag
'tag'
'tag'
...
@@ -176,8 +174,6 @@ def find():
...
@@ -176,8 +174,6 @@ def find():
def
parseliteral
():
def
parseliteral
():
r"""
r"""
>>> from xmlcore.etree import ElementTree as ET
>>> element = ET.XML("<html><body>text</body></html>")
>>> element = ET.XML("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
<html><body>text</body></html>
...
@@ -199,6 +195,19 @@ def parseliteral():
...
@@ -199,6 +195,19 @@ def parseliteral():
'body'
'body'
"""
"""
def
check_encoding
(
encoding
):
"""
>>> check_encoding("ascii")
>>> check_encoding("us-ascii")
>>> check_encoding("iso-8859-1")
>>> check_encoding("iso-8859-15")
>>> check_encoding("cp437")
>>> check_encoding("mac-roman")
"""
ET
.
XML
(
"<?xml version='1.0' encoding='%s'?><xml />"
%
encoding
)
#
#
# xinclude tests (samples from appendix C of the xinclude specification)
# xinclude tests (samples from appendix C of the xinclude specification)
...
@@ -273,15 +282,13 @@ def xinclude_loader(href, parse="xml", encoding=None):
...
@@ -273,15 +282,13 @@ def xinclude_loader(href, parse="xml", encoding=None):
except
KeyError
:
except
KeyError
:
raise
IOError
(
"resource not found"
)
raise
IOError
(
"resource not found"
)
if
parse
==
"xml"
:
if
parse
==
"xml"
:
from
xmlcore.etree.ElementTree
import
XML
return
ET
.
XML
(
data
)
return
XML
(
data
)
return
data
return
data
def
xinclude
():
def
xinclude
():
r"""
r"""
Basic inclusion example (XInclude C.1)
Basic inclusion example (XInclude C.1)
>>> from xmlcore.etree import ElementTree as ET
>>> from xmlcore.etree import ElementInclude
>>> from xmlcore.etree import ElementInclude
>>> document = xinclude_loader("C1.xml")
>>> document = xinclude_loader("C1.xml")
...
...
Lib/test/test_xml_etree_c.py
View file @
8911ca3d
...
@@ -4,6 +4,8 @@ import doctest, sys
...
@@ -4,6 +4,8 @@ import doctest, sys
from
test
import
test_support
from
test
import
test_support
from
xmlcore.etree
import
cElementTree
as
ET
SAMPLE_XML
=
"""
SAMPLE_XML
=
"""
<body>
<body>
<tag>text</tag>
<tag>text</tag>
...
@@ -55,8 +57,6 @@ def interface():
...
@@ -55,8 +57,6 @@ def interface():
"""
"""
Test element tree interface.
Test element tree interface.
>>> from xmlcore.etree import cElementTree as ET
>>> element = ET.Element("tag", key="value")
>>> element = ET.Element("tag", key="value")
>>> tree = ET.ElementTree(element)
>>> tree = ET.ElementTree(element)
...
@@ -104,8 +104,6 @@ def find():
...
@@ -104,8 +104,6 @@ def find():
"""
"""
Test find methods (including xpath syntax).
Test find methods (including xpath syntax).
>>> from xmlcore.etree import cElementTree as ET
>>> elem = ET.XML(SAMPLE_XML)
>>> elem = ET.XML(SAMPLE_XML)
>>> elem.find("tag").tag
>>> elem.find("tag").tag
'tag'
'tag'
...
@@ -172,8 +170,6 @@ def find():
...
@@ -172,8 +170,6 @@ def find():
def
parseliteral
():
def
parseliteral
():
r"""
r"""
>>> from xmlcore.etree import cElementTree as ET
>>> element = ET.XML("<html><body>text</body></html>")
>>> element = ET.XML("<html><body>text</body></html>")
>>> ET.ElementTree(element).write(sys.stdout)
>>> ET.ElementTree(element).write(sys.stdout)
<html><body>text</body></html>
<html><body>text</body></html>
...
@@ -195,6 +191,19 @@ def parseliteral():
...
@@ -195,6 +191,19 @@ def parseliteral():
'body'
'body'
"""
"""
def
check_encoding
(
encoding
):
"""
>>> check_encoding("ascii")
>>> check_encoding("us-ascii")
>>> check_encoding("iso-8859-1")
>>> check_encoding("iso-8859-15")
>>> check_encoding("cp437")
>>> check_encoding("mac-roman")
"""
ET
.
XML
(
"<?xml version='1.0' encoding='%s'?><xml />"
%
encoding
)
def
test_main
():
def
test_main
():
from
test
import
test_xml_etree_c
from
test
import
test_xml_etree_c
test_support
.
run_doctest
(
test_xml_etree_c
,
verbosity
=
True
)
test_support
.
run_doctest
(
test_xml_etree_c
,
verbosity
=
True
)
...
...
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