Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f15351d

Browse files
committed
Merged revisions 78838-78839,78917,78919,78934,78937 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r78838 | florent.xicluna | 2010-03-11 15:36:19 +0100 (jeu, 11 mar 2010) | 2 lines Issue #6472: The xml.etree package is updated to ElementTree 1.3. The cElementTree module is updated too. ........ r78839 | florent.xicluna | 2010-03-11 16:55:11 +0100 (jeu, 11 mar 2010) | 2 lines Fix repr of tree Element on windows. ........ r78917 | florent.xicluna | 2010-03-13 12:18:49 +0100 (sam, 13 mar 2010) | 2 lines Move the xml test data to their own directory. ........ r78919 | florent.xicluna | 2010-03-13 13:41:48 +0100 (sam, 13 mar 2010) | 2 lines Do not chdir when running test_xml_etree, and enhance the findfile helper. ........ r78934 | florent.xicluna | 2010-03-13 18:56:19 +0100 (sam, 13 mar 2010) | 2 lines Update some parts of the xml.etree documentation. ........ r78937 | florent.xicluna | 2010-03-13 21:30:15 +0100 (sam, 13 mar 2010) | 3 lines Add the keyword argument "method=None" to the .write() method and the tostring/tostringlist functions. Update the function, class and method signatures, according to the new convention. ........
1 parent 9451a1c commit f15351d

19 files changed

Lines changed: 3498 additions & 1291 deletions

Doc/library/xml.etree.elementtree.rst

Lines changed: 315 additions & 207 deletions
Large diffs are not rendered by default.

Doc/library/xml.etree.rst

Lines changed: 0 additions & 23 deletions
This file was deleted.

Lib/test/support.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,14 @@ def temp_cwd(name='tempcwd', quiet=False):
402402
rmtree(name)
403403

404404

405-
def findfile(file, here=__file__):
405+
def findfile(file, here=__file__, subdir=None):
406406
"""Try to find a file on sys.path and the working directory. If it is not
407407
found the argument passed to the function is returned (this does not
408408
necessarily signal failure; could still be the legitimate path)."""
409409
if os.path.isabs(file):
410410
return file
411+
if subdir is not None:
412+
file = os.path.join(subdir, file)
411413
path = sys.path
412414
path = [os.path.dirname(here)] + path
413415
for dn in path:

Lib/test/test_minidom.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# test for xml.dom.minidom
22

3-
import os
4-
import sys
53
import pickle
6-
from test.support import verbose, run_unittest
4+
from test.support import verbose, run_unittest, findfile
75
import unittest
86

97
import xml.dom
@@ -14,12 +12,8 @@
1412
from xml.dom.minidom import getDOMImplementation
1513

1614

17-
if __name__ == "__main__":
18-
base = sys.argv[0]
19-
else:
20-
base = __file__
21-
tstfile = os.path.join(os.path.dirname(base), "test.xml")
22-
del base
15+
tstfile = findfile("test.xml", subdir="xmltestdata")
16+
2317

2418
# The tests of DocumentType importing use these helpers to construct
2519
# the documents to work with, since not all DOM builders actually

Lib/test/test_sax.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
from io import StringIO
1616
from test.support import findfile, run_unittest
1717
import unittest
18-
import os
18+
19+
TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata")
20+
TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata")
1921

2022
ns_uri = "http://www.python.org/xml-ns/saxtest/"
2123

@@ -311,7 +313,7 @@ def test_filter_basic(self):
311313
#
312314
# ===========================================================================
313315

314-
xml_test_out = open(findfile("test.xml.out")).read()
316+
xml_test_out = open(TEST_XMLFILE_OUT).read()
315317

316318
class ExpatReaderTest(XmlTestBase):
317319

@@ -323,7 +325,7 @@ def test_expat_file(self):
323325
xmlgen = XMLGenerator(result)
324326

325327
parser.setContentHandler(xmlgen)
326-
parser.parse(open(findfile("test.xml")))
328+
parser.parse(open(TEST_XMLFILE))
327329

328330
self.assertEquals(result.getvalue(), xml_test_out)
329331

@@ -452,7 +454,7 @@ def test_expat_inpsource_filename(self):
452454
xmlgen = XMLGenerator(result)
453455

454456
parser.setContentHandler(xmlgen)
455-
parser.parse(findfile("test.xml"))
457+
parser.parse(TEST_XMLFILE)
456458

457459
self.assertEquals(result.getvalue(), xml_test_out)
458460

@@ -462,7 +464,7 @@ def test_expat_inpsource_sysid(self):
462464
xmlgen = XMLGenerator(result)
463465

464466
parser.setContentHandler(xmlgen)
465-
parser.parse(InputSource(findfile("test.xml")))
467+
parser.parse(InputSource(TEST_XMLFILE))
466468

467469
self.assertEquals(result.getvalue(), xml_test_out)
468470

@@ -473,7 +475,7 @@ def test_expat_inpsource_stream(self):
473475

474476
parser.setContentHandler(xmlgen)
475477
inpsrc = InputSource()
476-
inpsrc.setByteStream(open(findfile("test.xml")))
478+
inpsrc.setByteStream(open(TEST_XMLFILE))
477479
parser.parse(inpsrc)
478480

479481
self.assertEquals(result.getvalue(), xml_test_out)
@@ -534,9 +536,9 @@ def test_expat_locator_withinfo(self):
534536
xmlgen = XMLGenerator(result)
535537
parser = create_parser()
536538
parser.setContentHandler(xmlgen)
537-
parser.parse(findfile("test.xml"))
539+
parser.parse(TEST_XMLFILE)
538540

539-
self.assertEquals(parser.getSystemId(), findfile("test.xml"))
541+
self.assertEquals(parser.getSystemId(), TEST_XMLFILE)
540542
self.assertEquals(parser.getPublicId(), None)
541543

542544

0 commit comments

Comments
 (0)