MCPcopy Index your code
hub / github.com/python/cpython / test_dir_order_without_pathext_extension

Method test_dir_order_without_pathext_extension

Lib/test/test_shutil.py:2692–2720  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2690
2691 @unittest.skipUnless(sys.platform == "win32", 'test specific to Windows')
2692 def test_dir_order_without_pathext_extension(self):
2693 cmd = self.file[:-4] # without .exe extension
2694 search_path = os.pathsep.join([os.fsdecode(self.other_dir),
2695 os.fsdecode(self.dir)])
2696 # pathext match in the second directory
2697 self.assertNormEqual(shutil.which(cmd, path=search_path), self.filepath)
2698 self.assertNormEqual(shutil.which(cmd, path=search_path, mode=os.F_OK),
2699 self.filepath)
2700
2701 # without extension
2702 other_file_path = os.path.join(self.other_dir, cmd)
2703 self.create_file(other_file_path)
2704
2705 # pathext match in the second directory
2706 self.assertNormEqual(shutil.which(cmd, path=search_path), self.filepath)
2707 # full match in the first directory
2708 self.assertNormEqual(shutil.which(cmd, path=search_path, mode=os.F_OK),
2709 other_file_path)
2710 # full match in the second directory
2711 self.assertNormEqual(shutil.which(self.file, path=search_path), self.filepath)
2712 self.assertNormEqual(shutil.which(self.file, path=search_path, mode=os.F_OK),
2713 self.filepath)
2714
2715 # pathext match in the first directory
2716 search_path = os.pathsep.join([os.fsdecode(self.dir),
2717 os.fsdecode(self.other_dir)])
2718 self.assertNormEqual(shutil.which(cmd, path=search_path), self.filepath)
2719 self.assertNormEqual(shutil.which(cmd, path=search_path, mode=os.F_OK),
2720 self.filepath)
2721
2722
2723class TestWhichBytes(TestWhich):

Callers

nothing calls this directly

Calls 3

assertNormEqualMethod · 0.95
create_fileMethod · 0.95
joinMethod · 0.45

Tested by

no test coverage detected