mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 10:31:46 +04:00
Add support for requirements files in additional_dependencies
This commit is contained in:
parent
2006a508d8
commit
b591d27345
5 changed files with 409 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ import io
|
|||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
|
@ -843,3 +844,50 @@ def test_manifest_hooks(tempdir_factory, store):
|
|||
'exclude_types': [],
|
||||
'verbose': False,
|
||||
}
|
||||
|
||||
|
||||
def test_python_additional_dependencies_requirements_file(
|
||||
tempdir_factory,
|
||||
store,
|
||||
):
|
||||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||
req1 = os.path.join(path, 'req1.txt')
|
||||
with open(req1, 'w') as wfh:
|
||||
wfh.write(textwrap.dedent('''
|
||||
# This is a comment in the pip file
|
||||
pep8
|
||||
'''))
|
||||
with cwd(path):
|
||||
config = make_config_from_repo(path)
|
||||
config['hooks'][0]['additional_dependencies'] = ['-r', 'req1.txt']
|
||||
repo = Repository.create(config, store)
|
||||
env, = repo._venvs()
|
||||
assert env == (
|
||||
mock.ANY, 'python', python.get_default_version(), ('pep8',),
|
||||
)
|
||||
config = make_config_from_repo(path)
|
||||
config['hooks'][0]['additional_dependencies'] = ['-rreq1.txt']
|
||||
repo = Repository.create(config, store)
|
||||
env, = repo._venvs()
|
||||
assert env == (
|
||||
mock.ANY, 'python', python.get_default_version(), ('pep8',),
|
||||
)
|
||||
config = make_config_from_repo(path)
|
||||
config['hooks'][0]['additional_dependencies'] = [
|
||||
'--requirement',
|
||||
'req1.txt',
|
||||
]
|
||||
repo = Repository.create(config, store)
|
||||
env, = repo._venvs()
|
||||
assert env == (
|
||||
mock.ANY, 'python', python.get_default_version(), ('pep8',),
|
||||
)
|
||||
config = make_config_from_repo(path)
|
||||
config['hooks'][0]['additional_dependencies'] = [
|
||||
'--requirement=req1.txt',
|
||||
]
|
||||
repo = Repository.create(config, store)
|
||||
env, = repo._venvs()
|
||||
assert env == (
|
||||
mock.ANY, 'python', python.get_default_version(), ('pep8',),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue