summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-06-22 21:33:05 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-06-22 21:33:05 (GMT)
commit07c24d13ed3902ed6d85e70602e3f77cca098b16 (patch)
tree5f624f9f268a890ab9ac6dd9ed18bf74ff66d610 /Lib/test
parent849349de05aef4de3ad1f3b5d8936b3fc79d4c84 (diff)
downloadcpython-07c24d13ed3902ed6d85e70602e3f77cca098b16.zip
cpython-07c24d13ed3902ed6d85e70602e3f77cca098b16.tar.gz
cpython-07c24d13ed3902ed6d85e70602e3f77cca098b16.tar.bz2
Issue #444582: shutil.which() respects relative paths.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_shutil.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 96084ec..559f05b 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -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)