mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Do not chdir when running test_xml_etree, and enhance the findfile helper.
This commit is contained in:
parent
13ba1a1c65
commit
1b51c3d4de
4 changed files with 12 additions and 27 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue