mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Mock find_executable for find_by_sys_executable test
This commit is contained in:
parent
fa2e154b41
commit
c377830898
1 changed files with 7 additions and 1 deletions
|
|
@ -44,6 +44,12 @@ def test_sys_executable_matches_does_not_match(v):
|
|||
),
|
||||
)
|
||||
def test_find_by_sys_executable(exe, realpath, expected):
|
||||
def mocked_find_executable(exe):
|
||||
return exe.rpartition('/')[2]
|
||||
with mock.patch.object(sys, 'executable', exe):
|
||||
with mock.patch('os.path.realpath', return_value=realpath):
|
||||
assert python._find_by_sys_executable() == expected
|
||||
with mock.patch(
|
||||
'pre_commit.parse_shebang.find_executable',
|
||||
side_effect=mocked_find_executable,
|
||||
):
|
||||
assert python._find_by_sys_executable() == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue