[Python-checkins] r78917 - in python/trunk: Lib/test/samples Lib/test/test.xml Lib/test/test.xml.out Lib/test/test_minidom.py Lib/test/test_sax.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py Lib/test/xmltestdata Lib/test/xmltestdata/test.xml Lib/test/xmltestdata/test.xml.out Makefile.pre.in Tools/msi/msi.py

florent.xicluna python-checkins at python.org
Sat Mar 13 12:18:49 CET 2010


Author: florent.xicluna
Date: Sat Mar 13 12:18:49 2010
New Revision: 78917

Log:
Move the xml test data to their own directory.


Added:
   python/trunk/Lib/test/xmltestdata/
      - copied from r78869, /python/trunk/Lib/test/samples/
   python/trunk/Lib/test/xmltestdata/test.xml
      - copied unchanged from r78909, /python/trunk/Lib/test/test.xml
   python/trunk/Lib/test/xmltestdata/test.xml.out
      - copied unchanged from r78909, /python/trunk/Lib/test/test.xml.out
Removed:
   python/trunk/Lib/test/samples/
   python/trunk/Lib/test/test.xml
   python/trunk/Lib/test/test.xml.out
Modified:
   python/trunk/Lib/test/test_minidom.py
   python/trunk/Lib/test/test_sax.py
   python/trunk/Lib/test/test_xml_etree.py
   python/trunk/Lib/test/test_xml_etree_c.py
   python/trunk/Makefile.pre.in
   python/trunk/Tools/msi/msi.py

Deleted: python/trunk/Lib/test/test.xml
==============================================================================
--- python/trunk/Lib/test/test.xml	Sat Mar 13 12:18:49 2010
+++ (empty file)
@@ -1,115 +0,0 @@
-<?xml version="1.0"?>
-<HTML xmlns:pp="http://www.isogen.com/paul/post-processor">
-<TITLE>Introduction to XSL</TITLE>
-<H1>Introduction to XSL</H1>
-	
-
-	
-		<HR/>
-		<H2>Overview
-</H2>
-		<UL>
-		
-	<LI>1.Intro</LI>
-
-	<LI>2.History</LI>
-
-	<LI>3.XSL Basics</LI>
-
-	<LI>Lunch</LI>
-
-	<LI>4.An XML Data Model</LI>
-
-	<LI>5.XSL Patterns</LI>
-
-	<LI>6.XSL Templates</LI>
-
-	<LI>7.XSL Formatting Model
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR/>
-		<H2>Intro</H2>
-		<UL>
-		
-	<LI>Who am I?</LI>
-
-	<LI>Who are you?</LI>
-
-	<LI>Why are we here?
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR/>
-		<H2>History: XML and SGML</H2>
-		<UL>
-		
-	<LI>XML is a subset of SGML.</LI>
-
-	<LI>SGML allows the separation of abstract content from formatting.</LI>
-
-	<LI>Also one of XML's primary virtues (in the doc publishing domain).
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR/>
-		<H2>History: What are stylesheets?</H2>
-		<UL>
-		
-	<LI>Stylesheets specify the formatting of SGML/XML documents.</LI>
-
-	<LI>Stylesheets put the &quot;style&quot; back into documents.</LI>
-
-	<LI>New York Times content+NYT Stylesheet = NYT paper
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR/>
-		<H2>History: FOSI</H2>
-		<UL>
-		
-	<LI>FOSI: &quot;Formatted Output Specification Instance&quot;
-<UL>
-	<LI>MIL-STD-28001
-	</LI>
-
-	<LI>FOSI's are SGML documents
-	</LI>
-
-	<LI>A stylesheet for another document
-	</LI>
-</UL></LI>
-
-	<LI>Obsolete but implemented...
-</LI>
-
-		</UL>
-	
-
-
-	
-</HTML>

Deleted: python/trunk/Lib/test/test.xml.out
==============================================================================
--- python/trunk/Lib/test/test.xml.out	Sat Mar 13 12:18:49 2010
+++ (empty file)
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<HTML xmlns:pp="http://www.isogen.com/paul/post-processor">
-<TITLE>Introduction to XSL</TITLE>
-<H1>Introduction to XSL</H1>
-	
-
-	
-		<HR></HR>
-		<H2>Overview
-</H2>
-		<UL>
-		
-	<LI>1.Intro</LI>
-
-	<LI>2.History</LI>
-
-	<LI>3.XSL Basics</LI>
-
-	<LI>Lunch</LI>
-
-	<LI>4.An XML Data Model</LI>
-
-	<LI>5.XSL Patterns</LI>
-
-	<LI>6.XSL Templates</LI>
-
-	<LI>7.XSL Formatting Model
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR></HR>
-		<H2>Intro</H2>
-		<UL>
-		
-	<LI>Who am I?</LI>
-
-	<LI>Who are you?</LI>
-
-	<LI>Why are we here?
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR></HR>
-		<H2>History: XML and SGML</H2>
-		<UL>
-		
-	<LI>XML is a subset of SGML.</LI>
-
-	<LI>SGML allows the separation of abstract content from formatting.</LI>
-
-	<LI>Also one of XML's primary virtues (in the doc publishing domain).
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR></HR>
-		<H2>History: What are stylesheets?</H2>
-		<UL>
-		
-	<LI>Stylesheets specify the formatting of SGML/XML documents.</LI>
-
-	<LI>Stylesheets put the "style" back into documents.</LI>
-
-	<LI>New York Times content+NYT Stylesheet = NYT paper
-</LI>
-
-		</UL>
-	
-
-
-	
-
-	
-		<HR></HR>
-		<H2>History: FOSI</H2>
-		<UL>
-		
-	<LI>FOSI: "Formatted Output Specification Instance"
-<UL>
-	<LI>MIL-STD-28001
-	</LI>
-
-	<LI>FOSI's are SGML documents
-	</LI>
-
-	<LI>A stylesheet for another document
-	</LI>
-</UL></LI>
-
-	<LI>Obsolete but implemented...
-</LI>
-
-		</UL>
-	
-
-
-	
-</HTML>
\ No newline at end of file

Modified: python/trunk/Lib/test/test_minidom.py
==============================================================================
--- python/trunk/Lib/test/test_minidom.py	(original)
+++ python/trunk/Lib/test/test_minidom.py	Sat Mar 13 12:18:49 2010
@@ -19,7 +19,7 @@
     base = sys.argv[0]
 else:
     base = __file__
-tstfile = os.path.join(os.path.dirname(base), "test"+os.extsep+"xml")
+tstfile = os.path.join(os.path.dirname(base), "xmltestdata", "test.xml")
 del base
 
 # The tests of DocumentType importing use these helpers to construct

Modified: python/trunk/Lib/test/test_sax.py
==============================================================================
--- python/trunk/Lib/test/test_sax.py	(original)
+++ python/trunk/Lib/test/test_sax.py	Sat Mar 13 12:18:49 2010
@@ -17,6 +17,9 @@
 import unittest
 import os
 
+TEST_XMLFILE = findfile(os.path.join("xmltestdata", "test.xml"))
+TEST_XMLFILE_OUT = findfile(os.path.join("xmltestdata", "test.xml.out"))
+
 ns_uri = "http://www.python.org/xml-ns/saxtest/"
 
 class XmlTestBase(unittest.TestCase):
@@ -311,7 +314,7 @@
 #
 # ===========================================================================
 
-xml_test_out = open(findfile("test"+os.extsep+"xml"+os.extsep+"out")).read()
+xml_test_out = open(TEST_XMLFILE_OUT).read()
 
 class ExpatReaderTest(XmlTestBase):
 
@@ -323,7 +326,7 @@
         xmlgen = XMLGenerator(result)
 
         parser.setContentHandler(xmlgen)
-        parser.parse(open(findfile("test"+os.extsep+"xml")))
+        parser.parse(open(TEST_XMLFILE))
 
         self.assertEquals(result.getvalue(), xml_test_out)
 
@@ -452,7 +455,7 @@
         xmlgen = XMLGenerator(result)
 
         parser.setContentHandler(xmlgen)
-        parser.parse(findfile("test"+os.extsep+"xml"))
+        parser.parse(TEST_XMLFILE)
 
         self.assertEquals(result.getvalue(), xml_test_out)
 
@@ -462,7 +465,7 @@
         xmlgen = XMLGenerator(result)
 
         parser.setContentHandler(xmlgen)
-        parser.parse(InputSource(findfile("test"+os.extsep+"xml")))
+        parser.parse(InputSource(TEST_XMLFILE))
 
         self.assertEquals(result.getvalue(), xml_test_out)
 
@@ -473,7 +476,7 @@
 
         parser.setContentHandler(xmlgen)
         inpsrc = InputSource()
-        inpsrc.setByteStream(open(findfile("test"+os.extsep+"xml")))
+        inpsrc.setByteStream(open(TEST_XMLFILE))
         parser.parse(inpsrc)
 
         self.assertEquals(result.getvalue(), xml_test_out)
@@ -534,9 +537,9 @@
         xmlgen = XMLGenerator(result)
         parser = create_parser()
         parser.setContentHandler(xmlgen)
-        parser.parse(findfile("test.xml"))
+        parser.parse(TEST_XMLFILE)
 
-        self.assertEquals(parser.getSystemId(), findfile("test.xml"))
+        self.assertEquals(parser.getSystemId(), TEST_XMLFILE)
         self.assertEquals(parser.getPublicId(), None)
 
 

Modified: python/trunk/Lib/test/test_xml_etree.py
==============================================================================
--- python/trunk/Lib/test/test_xml_etree.py	(original)
+++ python/trunk/Lib/test/test_xml_etree.py	Sat Mar 13 12:18:49 2010
@@ -17,6 +17,9 @@
 
 from xml.etree import ElementTree as ET
 
+SIMPLE_XMLFILE = "xmltestdata/simple.xml"
+SIMPLE_NS_XMLFILE = "xmltestdata/simple-ns.xml"
+
 SAMPLE_XML = """\
 <body>
   <tag class='a'>text</tag>
@@ -418,7 +421,7 @@
     >>> tree.find("section/tag").tag
     'tag'
 
-    >>> tree = ET.ElementTree(file="samples/simple.xml")
+    >>> tree = ET.ElementTree(file=SIMPLE_XMLFILE)
     >>> tree.find("element").tag
     'element'
     >>> tree.find("element/../empty-element").tag
@@ -564,7 +567,7 @@
     """
     Test parsing from file.
 
-    >>> tree = ET.parse("samples/simple.xml")
+    >>> tree = ET.parse(SIMPLE_XMLFILE)
     >>> normalize_crlf(tree)
     >>> tree.write(sys.stdout)
     <root>
@@ -572,7 +575,7 @@
        <element>text</element>tail
        <empty-element />
     </root>
-    >>> tree = ET.parse("samples/simple-ns.xml")
+    >>> tree = ET.parse(SIMPLE_NS_XMLFILE)
     >>> normalize_crlf(tree)
     >>> tree.write(sys.stdout)
     <ns0:root xmlns:ns0="namespace">
@@ -584,7 +587,7 @@
     >>> parser = ET.XMLParser()
     >>> parser.version  # XXX: Upgrade to 2.0.1?
     'Expat 2.0.0'
-    >>> parser.feed(open("samples/simple.xml").read())
+    >>> parser.feed(open(SIMPLE_XMLFILE).read())
     >>> print serialize(parser.close())
     <root>
        <element key="value">text</element>
@@ -593,7 +596,7 @@
     </root>
 
     >>> parser = ET.XMLTreeBuilder() # 1.2 compatibility
-    >>> parser.feed(open("samples/simple.xml").read())
+    >>> parser.feed(open(SIMPLE_XMLFILE).read())
     >>> print serialize(parser.close())
     <root>
        <element key="value">text</element>
@@ -603,7 +606,7 @@
 
     >>> target = ET.TreeBuilder()
     >>> parser = ET.XMLParser(target=target)
-    >>> parser.feed(open("samples/simple.xml").read())
+    >>> parser.feed(open(SIMPLE_XMLFILE).read())
     >>> print serialize(parser.close())
     <root>
        <element key="value">text</element>
@@ -644,7 +647,7 @@
 
     >>> iterparse = ET.iterparse
 
-    >>> context = iterparse("samples/simple.xml")
+    >>> context = iterparse(SIMPLE_XMLFILE)
     >>> action, elem = next(context)
     >>> print action, elem.tag
     end element
@@ -656,7 +659,7 @@
     >>> context.root.tag
     'root'
 
-    >>> context = iterparse("samples/simple-ns.xml")
+    >>> context = iterparse(SIMPLE_NS_XMLFILE)
     >>> for action, elem in context:
     ...   print action, elem.tag
     end {namespace}element
@@ -665,17 +668,17 @@
     end {namespace}root
 
     >>> events = ()
-    >>> context = iterparse("samples/simple.xml", events)
+    >>> context = iterparse(SIMPLE_XMLFILE, events)
     >>> for action, elem in context:
     ...   print action, elem.tag
 
     >>> events = ()
-    >>> context = iterparse("samples/simple.xml", events=events)
+    >>> context = iterparse(SIMPLE_XMLFILE, events=events)
     >>> for action, elem in context:
     ...   print action, elem.tag
 
     >>> events = ("start", "end")
-    >>> context = iterparse("samples/simple.xml", events)
+    >>> context = iterparse(SIMPLE_XMLFILE, events)
     >>> for action, elem in context:
     ...   print action, elem.tag
     start root
@@ -688,7 +691,7 @@
     end root
 
     >>> events = ("start", "end", "start-ns", "end-ns")
-    >>> context = iterparse("samples/simple-ns.xml", events)
+    >>> context = iterparse(SIMPLE_NS_XMLFILE, events)
     >>> for action, elem in context:
     ...   if action in ("start", "end"):
     ...     print action, elem.tag
@@ -706,7 +709,7 @@
     end-ns None
 
     >>> events = ("start", "end", "bogus")
-    >>> context = iterparse("samples/simple.xml", events)
+    >>> context = iterparse(SIMPLE_XMLFILE, events)
     Traceback (most recent call last):
     ValueError: unknown event 'bogus'
 
@@ -767,7 +770,7 @@
     ...         pass
     >>> builder = Builder()
     >>> parser = ET.XMLParser(target=builder)
-    >>> parser.feed(open("samples/simple.xml", "r").read())
+    >>> parser.feed(open(SIMPLE_XMLFILE, "r").read())
     start root
     start element
     end element
@@ -790,7 +793,7 @@
     ...         print "comment", repr(data)
     >>> builder = Builder()
     >>> parser = ET.XMLParser(target=builder)
-    >>> parser.feed(open("samples/simple-ns.xml", "r").read())
+    >>> parser.feed(open(SIMPLE_NS_XMLFILE, "r").read())
     pi pi 'data'
     comment ' comment '
     start {namespace}root
@@ -808,7 +811,7 @@
     """
     Test Element.getchildren()
 
-    >>> tree = ET.parse(open("samples/simple.xml", "r"))
+    >>> tree = ET.parse(open(SIMPLE_XMLFILE, "r"))
     >>> for elem in tree.getroot().iter():
     ...     summarize_list(elem.getchildren())
     ['element', 'element', 'empty-element']
@@ -1286,9 +1289,9 @@
 <?xml version='1.0'?>
 <document xmlns:xi="http://www.w3.org/2001/XInclude">
   <p>Example.</p>
-  <xi:include href="samples/simple.xml"/>
+  <xi:include href="{}"/>
 </document>
-"""
+""".format(SIMPLE_XMLFILE)
 
 def xinclude_loader(href, parse="xml", encoding=None):
     try:
@@ -1822,8 +1825,10 @@
     from test import test_xml_etree
     def ignore(message, category=DeprecationWarning):
         warnings.filterwarnings("ignore", message, category)
+
     # The same doctests are used for both the Python and the C implementations
     assert test_xml_etree.ET.__name__ == module_name
+
     with warnings.catch_warnings(), CleanContext():
         # Search behaviour is broken if search path starts with "/".
         ignore("This search is broken in 1.3 and earlier, and will be fixed "
@@ -1838,8 +1843,8 @@
 
         test_support.run_doctest(test_xml_etree, verbosity=True)
 
-        # The module should not be changed by the tests
-        assert test_xml_etree.ET.__name__ == module_name
+    # The module should not be changed by the tests
+    assert test_xml_etree.ET.__name__ == module_name
 
 if __name__ == '__main__':
     test_main()

Modified: python/trunk/Lib/test/test_xml_etree_c.py
==============================================================================
--- python/trunk/Lib/test/test_xml_etree_c.py	(original)
+++ python/trunk/Lib/test/test_xml_etree_c.py	Sat Mar 13 12:18:49 2010
@@ -22,13 +22,18 @@
     test_support.run_doctest(test_xml_etree_c, verbosity=True)
 
     # Assign the C implementation before running the doctests
+    # Patch the __name__, to prevent confusion with the pure Python test
     pyET = test_xml_etree.ET
+    py__name__ = test_xml_etree.__name__
     test_xml_etree.ET = cET
+    if __name__ != '__main__':
+        test_xml_etree.__name__ = __name__
     try:
         # Run the same test suite as xml.etree.ElementTree
         test_xml_etree.test_main(module_name='xml.etree.cElementTree')
     finally:
         test_xml_etree.ET = pyET
+        test_xml_etree.__name__ = py__name__
 
 if __name__ == '__main__':
     test_main()

Modified: python/trunk/Makefile.pre.in
==============================================================================
--- python/trunk/Makefile.pre.in	(original)
+++ python/trunk/Makefile.pre.in	Sat Mar 13 12:18:49 2010
@@ -833,7 +833,7 @@
 	plat-mac/lib-scriptpackages/Terminal 
 PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
 LIBSUBDIRS=	lib-tk site-packages test test/output test/data \
-		test/decimaltestdata \
+		test/decimaltestdata test/xmltestdata \
 		encodings compiler hotshot \
 		email email/mime email/test email/test/data \
 		json json/tests \

Modified: python/trunk/Tools/msi/msi.py
==============================================================================
--- python/trunk/Tools/msi/msi.py	(original)
+++ python/trunk/Tools/msi/msi.py	Sat Mar 13 12:18:49 2010
@@ -1005,8 +1005,6 @@
             lib.add_file("audiotest.au")
             lib.add_file("cfgparser.1")
             lib.add_file("sgml_input.html")
-            lib.add_file("test.xml")
-            lib.add_file("test.xml.out")
             lib.add_file("testtar.tar")
             lib.add_file("test_difflib_expect.html")
             lib.add_file("check_soundcard.vbs")
@@ -1018,6 +1016,9 @@
             lib.add_file("zipdir.zip")
         if dir=='decimaltestdata':
             lib.glob("*.decTest")
+        if dir=='xmltestdata':
+            lib.glob("*.xml")
+            lib.add_file("test.xml.out")
         if dir=='output':
             lib.glob("test_*")
         if dir=='idlelib':


More information about the Python-checkins mailing list