|
2 | 2 |
|
3 | 3 | import os.path |
4 | 4 | import shutil |
5 | | -import sys |
6 | 5 | from typing import Any |
7 | 6 | from unittest import mock |
8 | 7 |
|
@@ -876,25 +875,31 @@ def test_tags_on_repositories(in_tmpdir, tempdir_factory, store): |
876 | 875 | @pytest.fixture |
877 | 876 | def local_python_config(): |
878 | 877 | # Make a "local" hooks repo that just installs our other hooks repo |
879 | | - repo_path = get_resource_path('python_hooks_repo') |
| 878 | + repo_path = get_resource_path('python3_hooks_repo') |
880 | 879 | manifest = load_manifest(os.path.join(repo_path, C.MANIFEST_FILE)) |
881 | 880 | hooks = [ |
882 | 881 | dict(hook, additional_dependencies=[repo_path]) for hook in manifest |
883 | 882 | ] |
884 | 883 | return {'repo': 'local', 'hooks': hooks} |
885 | 884 |
|
886 | 885 |
|
887 | | -@pytest.mark.xfail( # pragma: win32 no cover |
888 | | - sys.platform == 'win32', |
889 | | - reason='microsoft/azure-pipelines-image-generation#989', |
890 | | -) |
891 | 886 | def test_local_python_repo(store, local_python_config): |
892 | | - hook = _get_hook(local_python_config, store, 'foo') |
| 887 | + hook = _get_hook(local_python_config, store, 'python3-hook') |
| 888 | + # language_version should have been adjusted to the interpreter version |
| 889 | + assert hook.language_version != C.DEFAULT |
| 890 | + ret, out = _hook_run(hook, ('filename',), color=False) |
| 891 | + assert ret == 0 |
| 892 | + assert _norm_out(out) == b"3\n['filename']\nHello World\n" |
| 893 | + |
| 894 | + |
| 895 | +def test_local_python_repo_python2(store, local_python_config): |
| 896 | + local_python_config['hooks'][0]['language_version'] = 'python2' |
| 897 | + hook = _get_hook(local_python_config, store, 'python3-hook') |
893 | 898 | # language_version should have been adjusted to the interpreter version |
894 | 899 | assert hook.language_version != C.DEFAULT |
895 | 900 | ret, out = _hook_run(hook, ('filename',), color=False) |
896 | 901 | assert ret == 0 |
897 | | - assert _norm_out(out) == b"['filename']\nHello World\n" |
| 902 | + assert _norm_out(out) == b"2\n['filename']\nHello World\n" |
898 | 903 |
|
899 | 904 |
|
900 | 905 | def test_default_language_version(store, local_python_config): |
|
0 commit comments