mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
Issue #444582: shutil.which() respects relative paths.
This commit is contained in:
parent
849349de05
commit
07c24d13ed
3 changed files with 13 additions and 3 deletions
|
@ -1157,6 +1157,16 @@ class TestWhich(unittest.TestCase):
|
|||
rv = shutil.which(self.file, path=self.dir, mode=os.W_OK)
|
||||
self.assertIsNone(rv)
|
||||
|
||||
def test_relative(self):
|
||||
old_cwd = os.getcwd()
|
||||
base_dir, tail_dir = os.path.split(self.dir)
|
||||
os.chdir(base_dir)
|
||||
try:
|
||||
rv = shutil.which(self.file, path=tail_dir)
|
||||
self.assertEqual(rv, os.path.join(tail_dir, self.file))
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
|
||||
def test_nonexistent_file(self):
|
||||
# Return None when no matching executable file is found on the path.
|
||||
rv = shutil.which("foo.exe", path=self.dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue