mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix python.healthy() check with stdlib module clashes
This commit is contained in:
parent
1509dc497e
commit
bfcee8ec9f
2 changed files with 11 additions and 0 deletions
|
|
@ -147,6 +147,7 @@ def py_interface(_dir, _make_venv):
|
||||||
retcode, _, _ = cmd_output_b(
|
retcode, _, _ = cmd_output_b(
|
||||||
'python', '-c',
|
'python', '-c',
|
||||||
'import ctypes, datetime, io, os, ssl, weakref',
|
'import ctypes, datetime, io, os, ssl, weakref',
|
||||||
|
cwd='/',
|
||||||
retcode=None,
|
retcode=None,
|
||||||
)
|
)
|
||||||
return retcode == 0
|
return retcode == 0
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ import sys
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
import pre_commit.constants as C
|
||||||
from pre_commit.languages import python
|
from pre_commit.languages import python
|
||||||
|
from pre_commit.prefix import Prefix
|
||||||
|
|
||||||
|
|
||||||
def test_norm_version_expanduser():
|
def test_norm_version_expanduser():
|
||||||
|
|
@ -48,3 +50,11 @@ def test_find_by_sys_executable(exe, realpath, expected):
|
||||||
with mock.patch.object(os.path, 'realpath', return_value=realpath):
|
with mock.patch.object(os.path, 'realpath', return_value=realpath):
|
||||||
with mock.patch.object(python, 'find_executable', lambda x: x):
|
with mock.patch.object(python, 'find_executable', lambda x: x):
|
||||||
assert python._find_by_sys_executable() == expected
|
assert python._find_by_sys_executable() == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_healthy_types_py_in_cwd(tmpdir):
|
||||||
|
with tmpdir.as_cwd():
|
||||||
|
# even if a `types.py` file exists, should still be healthy
|
||||||
|
tmpdir.join('types.py').ensure()
|
||||||
|
# this env doesn't actually exist (for test speed purposes)
|
||||||
|
assert python.healthy(Prefix(str(tmpdir)), C.DEFAULT) is True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue