Skip to content

Commit 154d918

Browse files
committed
Add failing test for pre-commit#229
1 parent a875231 commit 154d918

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/repository_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ def test_python_hook_args_with_spaces(tmpdir_factory, store):
7171
)
7272

7373

74+
@pytest.mark.integration
75+
def test_switch_language_versions_doesnt_clobber(tmpdir_factory, store):
76+
# We're using the python3 repo because it prints the python version
77+
path = make_repo(tmpdir_factory, 'python3_hooks_repo')
78+
79+
def run_on_version(version, expected_output):
80+
config = make_config_from_repo(
81+
path, hooks=[{'id': 'python3-hook', 'language_version': version}],
82+
)
83+
repo = Repository.create(config, store)
84+
hook_dict, = [
85+
hook
86+
for repo_hook_id, hook in repo.hooks
87+
if repo_hook_id == 'python3-hook'
88+
]
89+
ret = repo.run_hook(hook_dict, [])
90+
assert ret[0] == 0
91+
assert ret[1].replace('\r\n', '\n') == expected_output
92+
93+
run_on_version('python3.4', '3.4\n[]\nHello World\n')
94+
run_on_version('python3.3', '3.3\n[]\nHello World\n')
95+
96+
7497
@pytest.mark.integration
7598
def test_versioned_python_hook(tmpdir_factory, store):
7699
_test_hook_repo(

0 commit comments

Comments
 (0)