mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Address @asottile's review comments
This commit is contained in:
parent
c377830898
commit
38da98d2d6
2 changed files with 5 additions and 5 deletions
|
|
@ -66,7 +66,6 @@ def _find_by_sys_executable():
|
||||||
|
|
||||||
|
|
||||||
def _get_default_version(): # pragma: no cover (platform dependent)
|
def _get_default_version(): # pragma: no cover (platform dependent)
|
||||||
|
|
||||||
# First attempt from `sys.executable` (or the realpath)
|
# First attempt from `sys.executable` (or the realpath)
|
||||||
exe = _find_by_sys_executable()
|
exe = _find_by_sys_executable()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import sys
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pre_commit.parse_shebang
|
||||||
from pre_commit.languages import python
|
from pre_commit.languages import python
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -35,7 +36,7 @@ def test_sys_executable_matches_does_not_match(v):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'exe,realpath,expected', (
|
('exe', 'realpath', 'expected'), (
|
||||||
('/usr/bin/python3', '/usr/bin/python3.7', 'python3'),
|
('/usr/bin/python3', '/usr/bin/python3.7', 'python3'),
|
||||||
('/usr/bin/python', '/usr/bin/python3.7', 'python3.7'),
|
('/usr/bin/python', '/usr/bin/python3.7', 'python3.7'),
|
||||||
('/usr/bin/python', '/usr/bin/python', None),
|
('/usr/bin/python', '/usr/bin/python', None),
|
||||||
|
|
@ -47,9 +48,9 @@ def test_find_by_sys_executable(exe, realpath, expected):
|
||||||
def mocked_find_executable(exe):
|
def mocked_find_executable(exe):
|
||||||
return exe.rpartition('/')[2]
|
return exe.rpartition('/')[2]
|
||||||
with mock.patch.object(sys, 'executable', exe):
|
with mock.patch.object(sys, 'executable', exe):
|
||||||
with mock.patch('os.path.realpath', return_value=realpath):
|
with mock.patch.object(os.path, 'realpath', return_value=realpath):
|
||||||
with mock.patch(
|
with mock.patch.object(
|
||||||
'pre_commit.parse_shebang.find_executable',
|
pre_commit.parse_shebang, 'find_executable',
|
||||||
side_effect=mocked_find_executable,
|
side_effect=mocked_find_executable,
|
||||||
):
|
):
|
||||||
assert python._find_by_sys_executable() == expected
|
assert python._find_by_sys_executable() == expected
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue