diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-13 12:41:48 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-13 12:41:48 (GMT) |
commit | 1b51c3d4deb4e99fe8440ce9e6f82769e2a1b9be (patch) | |
tree | 1803f0b1f84dc7f33d9574d80ccac3bb14445eb8 /Lib/test/test_xml_etree.py | |
parent | 13ba1a1c6571dad26e3030525556ec4b552b0865 (diff) | |
download | cpython-1b51c3d4deb4e99fe8440ce9e6f82769e2a1b9be.zip cpython-1b51c3d4deb4e99fe8440ce9e6f82769e2a1b9be.tar.gz cpython-1b51c3d4deb4e99fe8440ce9e6f82769e2a1b9be.tar.bz2 |
Do not chdir when running test_xml_etree, and enhance the findfile helper.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r-- | Lib/test/test_xml_etree.py | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index b99e42a..cdb9fdf 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -14,11 +14,12 @@ import sys from test import test_support +from test.test_support import findfile from xml.etree import ElementTree as ET -SIMPLE_XMLFILE = "xmltestdata/simple.xml" -SIMPLE_NS_XMLFILE = "xmltestdata/simple-ns.xml" +SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata") +SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata") SAMPLE_XML = """\ <body> @@ -1791,30 +1792,19 @@ def check_issue6565(): class CleanContext(object): - """Provide default namespace mapping, path cache and working directory. + """Provide default namespace mapping and path cache.""" - Save and restore the default namespace mapping and the path cache. - Change directory to the "Lib/test/" directory: some tests open - xml files in the "samples/" directory relative to the test module. - """ def __enter__(self): - import os from xml.etree import ElementTree self._nsmap = ElementTree._namespace_map self._path_cache = ElementTree.ElementPath._cache - self._previous_cwd = os.getcwd() # Copy the default namespace mapping ElementTree._namespace_map = self._nsmap.copy() # Copy the path cache (should be empty) ElementTree.ElementPath._cache = self._path_cache.copy() - # Change directory to Lib/test/ - os.chdir(os.path.dirname(__file__)) def __exit__(self, *args): - import os from xml.etree import ElementTree - # Restore working directory - os.chdir(self._previous_cwd) # Restore mapping and path cache ElementTree._namespace_map = self._nsmap ElementTree.ElementPath._cache = self._path_cache |