Do not chdir when running test_xml_etree, and enhance the findfile helper.

This commit is contained in:
Florent Xicluna 2010-03-13 12:41:48 +00:00
parent 13ba1a1c65
commit 1b51c3d4de
4 changed files with 12 additions and 27 deletions

View file

@ -424,12 +424,14 @@ def temp_cwd(name='tempcwd', quiet=False):
rmtree(name)
def findfile(file, here=__file__):
def findfile(file, here=__file__, subdir=None):
"""Try to find a file on sys.path and the working directory. If it is not
found the argument passed to the function is returned (this does not
necessarily signal failure; could still be the legitimate path)."""
if os.path.isabs(file):
return file
if subdir is not None:
file = os.path.join(subdir, file)
path = sys.path
path = [os.path.dirname(here)] + path
for dn in path: