Skip to content

Commit b5af5a5

Browse files
committed
Add test for python_venv language
1 parent e8954e2 commit b5af5a5

File tree

12 files changed

+55
-15
lines changed

12 files changed

+55
-15
lines changed

pre_commit/languages/python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
ENVIRONMENT_DIR = 'py_env'
19-
HEALTH_MODS = ('datetime', 'io', 'os', 'ssl', 'weakref')
2019

2120

2221
def bin_dir(venv):
@@ -120,7 +119,8 @@ def in_env(prefix, language_version):
120119
def healthy(prefix, language_version):
121120
with in_env(prefix, language_version):
122121
retcode, _, _ = cmd_output(
123-
'python', '-c', 'import {}'.format(','.join(HEALTH_MODS)),
122+
'python', '-c',
123+
'import ctypes, datetime, io, os, ssl, weakref',
124124
retcode=None,
125125
)
126126
return retcode == 0

testing/resources/python3_hooks_repo/python3_hook/main.py renamed to testing/resources/python3_hooks_repo/py3_hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55

6-
def func():
6+
def main():
77
print(sys.version_info[0])
88
print(repr(sys.argv[1:]))
99
print('Hello World')
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
from setuptools import find_packages
21
from setuptools import setup
32

43
setup(
54
name='python3_hook',
65
version='0.0.0',
7-
packages=find_packages('.'),
8-
entry_points={
9-
'console_scripts': ['python3-hook = python3_hook.main:func'],
10-
},
6+
py_modules=['py3_hook'],
7+
entry_points={'console_scripts': ['python3-hook = py3_hook:main']},
118
)

testing/resources/python_hooks_repo/foo/main.py renamed to testing/resources/python_hooks_repo/foo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44

55

6-
def func():
6+
def main():
77
print(repr(sys.argv[1:]))
88
print('Hello World')
99
return 0

testing/resources/python_hooks_repo/foo/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
from setuptools import find_packages
21
from setuptools import setup
32

43
setup(
5-
name='Foo',
4+
name='foo',
65
version='0.0.0',
7-
packages=find_packages('.'),
8-
entry_points={
9-
'console_scripts': ['foo = foo.main:func'],
10-
},
6+
py_modules=['foo'],
7+
entry_points={'console_scripts': ['foo = foo:main']},
118
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- id: foo
2+
name: Foo
3+
entry: foo
4+
language: python_venv
5+
files: \.py$
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from __future__ import print_function
2+
3+
import sys
4+
5+
6+
def main():
7+
print(repr(sys.argv[1:]))
8+
print('Hello World')
9+
return 0

testing/resources/python3_hooks_repo/python3_hook/__init__.py renamed to testing/resources/python_venv_hooks_repo/foo/__init__.py

File renamed without changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name='foo',
5+
version='0.0.0',
6+
py_modules=['foo'],
7+
entry_points={'console_scripts': ['foo = foo:main']},
8+
)

0 commit comments

Comments
 (0)