Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(263150)

Side by Side Diff: Lib/test/test_xml_etree.py

Issue 2830: Copy cgi.escape() to html
Patch Set: Created 8 years, 12 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/lib2to3/tests/test_util.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # xml.etree test. This file contains enough tests to make sure that 1 # xml.etree test. This file contains enough tests to make sure that
2 # all included components work as they should. 2 # all included components work as they should.
3 # Large parts are extracted from the upstream test suite. 3 # Large parts are extracted from the upstream test suite.
4 4
5 # IMPORTANT: the same doctests are run from "test_xml_etree_c" in 5 # IMPORTANT: the same doctests are run from "test_xml_etree_c" in
6 # order to ensure consistency between the C implementation and the 6 # order to ensure consistency between the C implementation and the
7 # Python implementation. 7 # Python implementation.
8 # 8 #
9 # For this purpose, the module-level "ET" symbol is temporarily 9 # For this purpose, the module-level "ET" symbol is temporarily
10 # monkey-patched when running the "test_xml_etree_c" test suite. 10 # monkey-patched when running the "test_xml_etree_c" test suite.
11 # Don't re-import "xml.etree.ElementTree" module in the docstring, 11 # Don't re-import "xml.etree.ElementTree" module in the docstring,
12 # except if the test is specific to the Python implementation. 12 # except if the test is specific to the Python implementation.
13 13
14 import sys 14 import sys
15 import cgi 15 import html
16 import unittest 16 import unittest
17 17
18 from test import support 18 from test import support
19 from test.support import findfile 19 from test.support import findfile
20 20
21 from xml.etree import ElementTree as ET 21 from xml.etree import ElementTree as ET
22 22
23 SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata") 23 SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata")
24 try: 24 try:
25 SIMPLE_XMLFILE.encode("utf8") 25 SIMPLE_XMLFILE.encode("utf8")
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 </xi:include> 1312 </xi:include>
1313 </div> 1313 </div>
1314 """ 1314 """
1315 1315
1316 XINCLUDE["default.xml"] = """\ 1316 XINCLUDE["default.xml"] = """\
1317 <?xml version='1.0'?> 1317 <?xml version='1.0'?>
1318 <document xmlns:xi="http://www.w3.org/2001/XInclude"> 1318 <document xmlns:xi="http://www.w3.org/2001/XInclude">
1319 <p>Example.</p> 1319 <p>Example.</p>
1320 <xi:include href="{}"/> 1320 <xi:include href="{}"/>
1321 </document> 1321 </document>
1322 """.format(cgi.escape(SIMPLE_XMLFILE, True)) 1322 """.format(html.escape(SIMPLE_XMLFILE, True))
1323 1323
1324 def xinclude_loader(href, parse="xml", encoding=None): 1324 def xinclude_loader(href, parse="xml", encoding=None):
1325 try: 1325 try:
1326 data = XINCLUDE[href] 1326 data = XINCLUDE[href]
1327 except KeyError: 1327 except KeyError:
1328 raise IOError("resource not found") 1328 raise IOError("resource not found")
1329 if parse == "xml": 1329 if parse == "xml":
1330 from xml.etree.ElementTree import XML 1330 from xml.etree.ElementTree import XML
1331 return XML(data) 1331 return XML(data)
1332 return data 1332 return data
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 1878
1879 # XXX the C module should give the same warnings as the Python module 1879 # XXX the C module should give the same warnings as the Python module
1880 with CleanContext(quiet=not use_py_module): 1880 with CleanContext(quiet=not use_py_module):
1881 support.run_doctest(test_xml_etree, verbosity=True) 1881 support.run_doctest(test_xml_etree, verbosity=True)
1882 1882
1883 # The module should not be changed by the tests 1883 # The module should not be changed by the tests
1884 assert test_xml_etree.ET.__name__ == module_name 1884 assert test_xml_etree.ET.__name__ == module_name
1885 1885
1886 if __name__ == '__main__': 1886 if __name__ == '__main__':
1887 test_main() 1887 test_main()
OLDNEW
« no previous file with comments | « Lib/lib2to3/tests/test_util.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+