mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-15 13:30:17 -06:00
Address more @asottile's review comments
This commit is contained in:
@@ -68,6 +68,8 @@ def _find_by_sys_executable():
|
||||
def _get_default_version(): # pragma: no cover (platform dependent)
|
||||
# First attempt from `sys.executable` (or the realpath)
|
||||
exe = _find_by_sys_executable()
|
||||
if exe:
|
||||
return exe
|
||||
|
||||
# Next try the `pythonX.X` executable
|
||||
exe = 'python{}.{}'.format(*sys.version_info)
|
||||
|
||||
@@ -7,7 +7,7 @@ import sys
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
import pre_commit.parse_shebang
|
||||
from pre_commit import parse_shebang
|
||||
from pre_commit.languages import python
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_find_by_sys_executable(exe, realpath, expected):
|
||||
with mock.patch.object(sys, 'executable', exe):
|
||||
with mock.patch.object(os.path, 'realpath', return_value=realpath):
|
||||
with mock.patch.object(
|
||||
pre_commit.parse_shebang, 'find_executable',
|
||||
parse_shebang, 'find_executable',
|
||||
side_effect=mocked_find_executable,
|
||||
):
|
||||
assert python._find_by_sys_executable() == expected
|
||||
|
||||
Reference in New Issue
Block a user