diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-27 10:32:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-02-27 10:32:18 +0000 |
commit | a75e61fbe483eb1f3bbfb2d61d7c15615f56172b (patch) | |
tree | 2200a67ca0cbe0c8091c69a447c70c3b0ca0a79c /tests/languages/python_test.py | |
parent | Adding upstream version 3.0.4. (diff) | |
download | pre-commit-a75e61fbe483eb1f3bbfb2d61d7c15615f56172b.tar.xz pre-commit-a75e61fbe483eb1f3bbfb2d61d7c15615f56172b.zip |
Adding upstream version 3.1.0.upstream/3.1.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/languages/python_test.py')
-rw-r--r-- | tests/languages/python_test.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/languages/python_test.py b/tests/languages/python_test.py index 54fb98f..8bb284e 100644 --- a/tests/languages/python_test.py +++ b/tests/languages/python_test.py @@ -12,6 +12,7 @@ from pre_commit.languages import python from pre_commit.prefix import Prefix from pre_commit.util import make_executable from pre_commit.util import win_exe +from testing.language_helpers import run_language def test_read_pyvenv_cfg(tmpdir): @@ -210,3 +211,25 @@ def test_unhealthy_then_replaced(python_dir): os.replace(f'{py_exe}.tmp', py_exe) assert python.health_check(prefix, C.DEFAULT) is None + + +def test_language_versioned_python_hook(tmp_path): + setup_py = '''\ +from setuptools import setup +setup( + name='example', + py_modules=['mod'], + entry_points={'console_scripts': ['myexe=mod:main']}, +) +''' + tmp_path.joinpath('setup.py').write_text(setup_py) + tmp_path.joinpath('mod.py').write_text('def main(): print("ohai")') + + # we patch this to force virtualenv executing with `-p` since we can't + # reliably have multiple pythons available in CI + with mock.patch.object( + python, + '_sys_executable_matches', + return_value=False, + ): + assert run_language(tmp_path, python, 'myexe') == (0, b'ohai\n') |