Skip to content

Commit

Permalink
Address more @asottile's review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Aug 15, 2019
1 parent 38da98d commit 5622760
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pre_commit/languages/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def _norm(path):
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)
Expand Down
4 changes: 2 additions & 2 deletions tests/languages/python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mock
import pytest

import pre_commit.parse_shebang
from pre_commit import parse_shebang
from pre_commit.languages import python


Expand Down Expand Up @@ -50,7 +50,7 @@ def mocked_find_executable(exe):
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

0 comments on commit 5622760

Please sign in to comment.