mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 17:14:43 +04:00
move slowest python-specific tests out of repository_test
This commit is contained in:
parent
950451e1ef
commit
d3c0a66d23
2 changed files with 51 additions and 29 deletions
|
|
@ -233,3 +233,54 @@ setup(
|
||||||
return_value=False,
|
return_value=False,
|
||||||
):
|
):
|
||||||
assert run_language(tmp_path, python, 'myexe') == (0, b'ohai\n')
|
assert run_language(tmp_path, python, 'myexe') == (0, b'ohai\n')
|
||||||
|
|
||||||
|
|
||||||
|
def _make_hello_hello(tmp_path):
|
||||||
|
setup_py = '''\
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='socks',
|
||||||
|
version='0.0.0',
|
||||||
|
py_modules=['socks'],
|
||||||
|
entry_points={'console_scripts': ['socks = socks:main']},
|
||||||
|
)
|
||||||
|
'''
|
||||||
|
|
||||||
|
main_py = '''\
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print(repr(sys.argv[1:]))
|
||||||
|
print('hello hello')
|
||||||
|
return 0
|
||||||
|
'''
|
||||||
|
tmp_path.joinpath('setup.py').write_text(setup_py)
|
||||||
|
tmp_path.joinpath('socks.py').write_text(main_py)
|
||||||
|
|
||||||
|
|
||||||
|
def test_simple_python_hook(tmp_path):
|
||||||
|
_make_hello_hello(tmp_path)
|
||||||
|
|
||||||
|
ret = run_language(tmp_path, python, 'socks', [os.devnull])
|
||||||
|
assert ret == (0, f'[{os.devnull!r}]\nhello hello\n'.encode())
|
||||||
|
|
||||||
|
|
||||||
|
def test_simple_python_hook_default_version(tmp_path):
|
||||||
|
# make sure that this continues to work for platforms where default
|
||||||
|
# language detection does not work
|
||||||
|
with mock.patch.object(
|
||||||
|
python,
|
||||||
|
'get_default_version',
|
||||||
|
return_value=C.DEFAULT,
|
||||||
|
):
|
||||||
|
test_simple_python_hook(tmp_path)
|
||||||
|
|
||||||
|
|
||||||
|
def test_python_hook_weird_setup_cfg(tmp_path):
|
||||||
|
_make_hello_hello(tmp_path)
|
||||||
|
setup_cfg = '[install]\ninstall_scripts=/usr/sbin'
|
||||||
|
tmp_path.joinpath('setup.cfg').write_text(setup_cfg)
|
||||||
|
|
||||||
|
ret = run_language(tmp_path, python, 'socks', [os.devnull])
|
||||||
|
assert ret == (0, f'[{os.devnull!r}]\nhello hello\n'.encode())
|
||||||
|
|
|
||||||
|
|
@ -82,35 +82,6 @@ def _test_hook_repo(
|
||||||
assert out == expected
|
assert out == expected
|
||||||
|
|
||||||
|
|
||||||
def test_python_hook(tempdir_factory, store):
|
|
||||||
_test_hook_repo(
|
|
||||||
tempdir_factory, store, 'python_hooks_repo',
|
|
||||||
'foo', [os.devnull],
|
|
||||||
f'[{os.devnull!r}]\nHello World\n'.encode(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_python_hook_default_version(tempdir_factory, store):
|
|
||||||
# make sure that this continues to work for platforms where default
|
|
||||||
# language detection does not work
|
|
||||||
with mock.patch.object(
|
|
||||||
python,
|
|
||||||
'get_default_version',
|
|
||||||
return_value=C.DEFAULT,
|
|
||||||
):
|
|
||||||
test_python_hook(tempdir_factory, store)
|
|
||||||
|
|
||||||
|
|
||||||
def test_python_hook_weird_setup_cfg(in_git_dir, tempdir_factory, store):
|
|
||||||
in_git_dir.join('setup.cfg').write('[install]\ninstall_scripts=/usr/sbin')
|
|
||||||
|
|
||||||
_test_hook_repo(
|
|
||||||
tempdir_factory, store, 'python_hooks_repo',
|
|
||||||
'foo', [os.devnull],
|
|
||||||
f'[{os.devnull!r}]\nHello World\n'.encode(),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_python_venv_deprecation(store, caplog):
|
def test_python_venv_deprecation(store, caplog):
|
||||||
config = {
|
config = {
|
||||||
'repo': 'local',
|
'repo': 'local',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue