diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2005-12-16 22:07:17 (GMT) |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2005-12-16 22:07:17 (GMT) |
commit | 8911ca3d70d97d46bbc7c7b77293ecc8c45d4c1f (patch) | |
tree | 343e94ada31d45d0f01bc8c1c36c615d658ec432 /Lib/test/test_xml_etree_c.py | |
parent | 6d52b55c562e1c06811fa9816fe7ce708efa6a28 (diff) | |
download | cpython-8911ca3d70d97d46bbc7c7b77293ecc8c45d4c1f.zip cpython-8911ca3d70d97d46bbc7c7b77293ecc8c45d4c1f.tar.gz cpython-8911ca3d70d97d46bbc7c7b77293ecc8c45d4c1f.tar.bz2 |
added encoding tests to ElementTree/cElementTree tests
Diffstat (limited to 'Lib/test/test_xml_etree_c.py')
-rw-r--r-- | Lib/test/test_xml_etree_c.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index fcb6233..587ea99 100644 --- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -4,6 +4,8 @@ import doctest, sys from test import test_support +from xmlcore.etree import cElementTree as ET + SAMPLE_XML = """ <body> <tag>text</tag> @@ -55,8 +57,6 @@ def interface(): """ Test element tree interface. - >>> from xmlcore.etree import cElementTree as ET - >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) @@ -104,8 +104,6 @@ def find(): """ Test find methods (including xpath syntax). - >>> from xmlcore.etree import cElementTree as ET - >>> elem = ET.XML(SAMPLE_XML) >>> elem.find("tag").tag 'tag' @@ -172,8 +170,6 @@ def find(): def parseliteral(): r""" - >>> from xmlcore.etree import cElementTree as ET - >>> element = ET.XML("<html><body>text</body></html>") >>> ET.ElementTree(element).write(sys.stdout) <html><body>text</body></html> @@ -195,6 +191,19 @@ def parseliteral(): '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(): from test import test_xml_etree_c test_support.run_doctest(test_xml_etree_c, verbosity=True) |