summaryrefslogtreecommitdiff
path: root/Lib/test/test_shutil.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r--Lib/test/test_shutil.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 3b1b6949d0..a3e3a52264 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -24,6 +24,7 @@ import warnings
from test import support
from test.support import TESTFN, check_warnings, captured_stdout, requires_zlib
+from unittest.mock import patch
try:
import bz2
@@ -1352,6 +1353,26 @@ class TestWhich(unittest.TestCase):
rv = shutil.which(self.file[:-4], path=self.dir)
self.assertEqual(rv, self.temp_file.name[:-4] + ".EXE")
+ def test_environ_path(self):
+ with support.EnvironmentVarGuard() as env:
+ env['PATH'] = self.dir
+ rv = shutil.which(self.file)
+ self.assertEqual(rv, self.temp_file.name)
+
+ def test_empty_path(self):
+ base_dir = os.path.dirname(self.dir)
+ with support.temp_cwd(path=self.dir), \
+ support.EnvironmentVarGuard() as env:
+ env['PATH'] = self.dir
+ rv = shutil.which(self.file, path='')
+ self.assertIsNone(rv)
+
+ def test_empty_path_no_PATH(self):
+ with support.EnvironmentVarGuard() as env:
+ env.pop('PATH', None)
+ rv = shutil.which(self.file)
+ self.assertIsNone(rv)
+
class TestMove(unittest.TestCase):