diff --git a/tests/repository_test.py b/tests/repository_test.py index c0bd0796..e8cd0cee 100644 --- a/tests/repository_test.py +++ b/tests/repository_test.py @@ -71,6 +71,29 @@ def test_python_hook_args_with_spaces(tmpdir_factory, store): ) +@pytest.mark.integration +def test_switch_language_versions_doesnt_clobber(tmpdir_factory, store): + # We're using the python3 repo because it prints the python version + path = make_repo(tmpdir_factory, 'python3_hooks_repo') + + def run_on_version(version, expected_output): + config = make_config_from_repo( + path, hooks=[{'id': 'python3-hook', 'language_version': version}], + ) + repo = Repository.create(config, store) + hook_dict, = [ + hook + for repo_hook_id, hook in repo.hooks + if repo_hook_id == 'python3-hook' + ] + ret = repo.run_hook(hook_dict, []) + assert ret[0] == 0 + assert ret[1].replace('\r\n', '\n') == expected_output + + run_on_version('python3.4', '3.4\n[]\nHello World\n') + run_on_version('python3.3', '3.3\n[]\nHello World\n') + + @pytest.mark.integration def test_versioned_python_hook(tmpdir_factory, store): _test_hook_repo(