mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add failing test for versioned repositories.
This commit is contained in:
parent
3baae2fd1e
commit
fdd6989ece
6 changed files with 44 additions and 0 deletions
5
testing/resources/python3_hooks_repo/hooks.yaml
Normal file
5
testing/resources/python3_hooks_repo/hooks.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- id: python3-hook
|
||||||
|
name: Python 3 Hook
|
||||||
|
entry: python3-hook
|
||||||
|
language: python
|
||||||
|
language_version: python3.3
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def func():
|
||||||
|
print('{0}.{1}'.format(*sys.version_info[:2]))
|
||||||
|
print(repr(sys.argv[1:]))
|
||||||
|
print('Hello World')
|
||||||
|
return 0
|
||||||
11
testing/resources/python3_hooks_repo/setup.py
Normal file
11
testing/resources/python3_hooks_repo/setup.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
from setuptools import find_packages
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='python3_hook',
|
||||||
|
version='0.0.0',
|
||||||
|
packages=find_packages('.'),
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': ['python3-hook = python3_hook.main:func'],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
@ -72,6 +72,11 @@ def python_hooks_repo(dummy_git_repo):
|
||||||
yield _make_repo(dummy_git_repo, 'python_hooks_repo')
|
yield _make_repo(dummy_git_repo, 'python_hooks_repo')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.yield_fixture
|
||||||
|
def python3_hooks_repo(dummy_git_repo):
|
||||||
|
yield _make_repo(dummy_git_repo, 'python3_hooks_repo')
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def node_hooks_repo(dummy_git_repo):
|
def node_hooks_repo(dummy_git_repo):
|
||||||
yield _make_repo(dummy_git_repo, 'node_hooks_repo')
|
yield _make_repo(dummy_git_repo, 'node_hooks_repo')
|
||||||
|
|
@ -133,6 +138,11 @@ def config_for_python_hooks_repo(python_hooks_repo):
|
||||||
yield _make_config(python_hooks_repo, 'foo', '\\.py$')
|
yield _make_config(python_hooks_repo, 'foo', '\\.py$')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.yield_fixture
|
||||||
|
def config_for_python3_hooks_repo(python3_hooks_repo):
|
||||||
|
yield _make_config(python3_hooks_repo, 'python3-hook', '\\.py$')
|
||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture
|
@pytest.yield_fixture
|
||||||
def config_for_prints_cwd_repo(prints_cwd_repo):
|
def config_for_prints_cwd_repo(prints_cwd_repo):
|
||||||
yield _make_config(prints_cwd_repo, 'prints_cwd', '^$')
|
yield _make_config(prints_cwd_repo, 'prints_cwd', '^$')
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,15 @@ def test_run_a_python_hook(config_for_python_hooks_repo, store):
|
||||||
assert ret[1] == "['/dev/null']\nHello World\n"
|
assert ret[1] == "['/dev/null']\nHello World\n"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail
|
||||||
|
@pytest.mark.integration
|
||||||
|
def test_run_versioned_hook(config_for_python3_hooks_repo, store):
|
||||||
|
repo = Repository.create(config_for_python3_hooks_repo, store)
|
||||||
|
ret = repo.run_hook('python3-hook', ['/dev/null'])
|
||||||
|
assert ret[0] == 0
|
||||||
|
assert ret[1] == "3.3\n['/dev/null']\nHello World\n"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
def test_lots_of_files(config_for_python_hooks_repo, store):
|
def test_lots_of_files(config_for_python_hooks_repo, store):
|
||||||
repo = Repository.create(config_for_python_hooks_repo, store)
|
repo = Repository.create(config_for_python_hooks_repo, store)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue