Skip to content

Commit a6eb0d2

Browse files
authored
tests: fix git commit hook tests on python3.6 (#1780)
1 parent 7512924 commit a6eb0d2

File tree

4 files changed

+58
-13
lines changed

4 files changed

+58
-13
lines changed

.github/workflows/test_deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ jobs:
125125
git config --global --add user.name "Renku @ SDSC"
126126
git config --global --add user.email "[email protected]"
127127
- name: Test with pytest
128+
env:
129+
LANG: en_US.UTF-8
130+
LC_ALL: en_US.UTF-8
128131
run: pytest -v -m "not integration and not publish and not serial" -n auto tests/api
129132
- name: Coveralls
130133
env:
@@ -161,8 +164,14 @@ jobs:
161164
git config --global --add user.name "Renku @ SDSC"
162165
git config --global --add user.email "[email protected]"
163166
- name: Test with pytest
167+
env:
168+
LANG: en_US.UTF-8
169+
LC_ALL: en_US.UTF-8
164170
run: pytest -v -m "not integration and not publish and not serial" -n auto tests/cli
165171
- name: Test with pytest(serial)
172+
env:
173+
LANG: en_US.UTF-8
174+
LC_ALL: en_US.UTF-8
166175
run: pytest -v -m "not integration and not publish and serial" tests/cli
167176
- name: Coveralls
168177
env:
@@ -199,8 +208,14 @@ jobs:
199208
git config --global --add user.name "Renku @ SDSC"
200209
git config --global --add user.email "[email protected]"
201210
- name: Test with pytest
211+
env:
212+
LANG: en_US.UTF-8
213+
LC_ALL: en_US.UTF-8
202214
run: pytest -v -m "not integration and not publish and not serial" -n auto tests/core
203215
- name: Test with pytest(serial)
216+
env:
217+
LANG: en_US.UTF-8
218+
LC_ALL: en_US.UTF-8
204219
run: pytest -v -m "not integration and not publish and serial" tests/core
205220
- name: Coveralls
206221
env:
@@ -237,6 +252,9 @@ jobs:
237252
git config --global --add user.name "Renku @ SDSC"
238253
git config --global --add user.email "[email protected]"
239254
- name: Test with pytest
255+
env:
256+
LANG: en_US.UTF-8
257+
LC_ALL: en_US.UTF-8
240258
run: pytest -v -m "not integration and not publish" -n auto tests/service
241259
- name: Coveralls
242260
env:
@@ -271,6 +289,8 @@ jobs:
271289
git config --global --add user.email "[email protected]"
272290
- name: Test with pytest
273291
env:
292+
LANG: en_US.UTF-8
293+
LC_ALL: en_US.UTF-8
274294
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
275295
run: pytest -v -m "not integration and not publish and not serial" tests/api
276296

@@ -300,10 +320,14 @@ jobs:
300320
git config --global --add user.email "[email protected]"
301321
- name: Test with pytest
302322
env:
323+
LANG: en_US.UTF-8
324+
LC_ALL: en_US.UTF-8
303325
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
304326
run: pytest -v -m "not integration and not publish and not serial" tests/cli
305327
- name: Test with pytest(serial)
306328
env:
329+
LANG: en_US.UTF-8
330+
LC_ALL: en_US.UTF-8
307331
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
308332
run: pytest -v -m "not integration and not publish and serial" tests/cli
309333

@@ -333,10 +357,14 @@ jobs:
333357
git config --global --add user.email "[email protected]"
334358
- name: Test with pytest
335359
env:
360+
LANG: en_US.UTF-8
361+
LC_ALL: en_US.UTF-8
336362
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
337363
run: pytest -v -m "not integration and not publish and not serial" tests/core
338364
- name: Test with pytest(serial)
339365
env:
366+
LANG: en_US.UTF-8
367+
LC_ALL: en_US.UTF-8
340368
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
341369
run: pytest -v -m "not integration and not publish and serial" tests/core
342370

@@ -366,6 +394,8 @@ jobs:
366394
git config --global --add user.email "[email protected]"
367395
- name: Test with pytest
368396
env:
397+
LANG: en_US.UTF-8
398+
LC_ALL: en_US.UTF-8
369399
RENKU_REQUESTS_TIMEOUT_SECONDS: 120
370400
run: pytest -v -m "not integration and not publish" tests/service
371401

@@ -397,6 +427,8 @@ jobs:
397427
git config --global --add user.email "[email protected]"
398428
- name: Test with pytest
399429
env:
430+
LANG: en_US.UTF-8
431+
LC_ALL: en_US.UTF-8
400432
DATAVERSE_ACCESS_TOKEN: ${{ secrets.DATAVERSE_ACCESS_TOKEN }}
401433
IT_OAUTH_GIT_TOKEN: ${{ secrets.IT_OAUTH_GIT_TOKEN }}
402434
ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
@@ -430,6 +462,8 @@ jobs:
430462
git config --global --add user.email "[email protected]"
431463
- name: Test with pytest
432464
env:
465+
LANG: en_US.UTF-8
466+
LC_ALL: en_US.UTF-8
433467
DATAVERSE_ACCESS_TOKEN: ${{ secrets.DATAVERSE_ACCESS_TOKEN }}
434468
IT_OAUTH_GIT_TOKEN: ${{ secrets.IT_OAUTH_GIT_TOKEN }}
435469
ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}

renku/data/pre-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if [ ${#MODIFIED_FILES[@]} -ne 0 ] ; then
6666
echo 'To commit anyway, use "git commit --no-verify".'
6767
exit 1
6868
fi
69-
IMMUTABLE_TEMPLATE_FILES=$(renku migrate check-immutable-template-files "${MODIFIED_FILES[@]}")
69+
IMMUTABLE_TEMPLATE_FILES=$(renku check-immutable-template-files "${MODIFIED_FILES[@]}")
7070
if [ "$IMMUTABLE_TEMPLATE_FILES" ]; then
7171
echo 'You are trying to update files marked as immutable in your project template.'
7272
echo 'This would prevent the project from being updated with new versions of the template in the future.'

tests/cli/test_datasets.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,9 +1292,9 @@ def test_lfs_hook(runner, client, subdirectory, large_file):
12921292
# Commit fails when file is not tracked in LFS
12931293
with pytest.raises(git.exc.HookExecutionError) as e:
12941294
client.repo.index.commit("large files not in LFS")
1295-
output = str(e)
1296-
assert "You are trying to commit large files to Git" in output
1297-
assert large_file.name in output
1295+
1296+
assert "You are trying to commit large files to Git" in e.value.stdout
1297+
assert large_file.name in e.value.stdout
12981298

12991299
# Can be committed after being tracked in LFS
13001300
client.track_paths_in_storage(large_file.name)
@@ -1310,7 +1310,11 @@ def test_lfs_hook_autocommit(runner, client, subdirectory, large_file):
13101310
shutil.copy(large_file, client.path)
13111311
client.repo.git.add("--all")
13121312

1313-
result = client.repo.git.commit(message="large files not in LFS", with_extended_output=True)
1313+
result = client.repo.git.commit(
1314+
message="large files not in LFS",
1315+
with_extended_output=True,
1316+
env={"LC_ALL": "en_US.UTF-8", "LANG": "en_US.UTF-8"},
1317+
)
13141318
assert large_file.name in result[1]
13151319
assert ".gitattributes" in result[1]
13161320
assert "You are trying to commit large files to Git instead of Git-LFS" in result[2]
@@ -1325,7 +1329,11 @@ def test_lfs_hook_autocommit_env(runner, client, subdirectory, large_file):
13251329
shutil.copy(large_file, client.path)
13261330
client.repo.git.add("--all")
13271331

1328-
result = client.repo.git.commit(message="large files not in LFS", with_extended_output=True)
1332+
result = client.repo.git.commit(
1333+
message="large files not in LFS",
1334+
with_extended_output=True,
1335+
env={"LC_ALL": "en_US.UTF-8", "LANG": "en_US.UTF-8"},
1336+
)
13291337
assert large_file.name in result[1]
13301338
assert ".gitattributes" in result[1]
13311339
assert "You are trying to commit large files to Git instead of Git-LFS" in result[2]

tests/core/commands/test_cli.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def test_git_pre_commit_hook(runner, project, capsys):
113113
repo.git.add("--all")
114114
with pytest.raises(git.HookExecutionError) as error:
115115
repo.index.commit("hello")
116-
assert output.name in error.stdout
116+
117+
assert output.name in error.value.stdout
117118

118119
result = runner.invoke(cli, ["githooks", "uninstall"])
119120
assert 0 == result.exit_code
@@ -133,9 +134,9 @@ def test_git_pre_commit_hook_in_old_project(isolated_runner, old_dataset_project
133134
with pytest.raises(git.exc.HookExecutionError) as e:
134135
old_dataset_project.repo.index.commit("update project metadata")
135136

136-
assert "Cannot verify validity of the commit: Project metadata is outdated." in str(e.value)
137-
assert "Run 'renku migrate' command to fix the issue." in str(e.value)
138-
assert "You are trying to update generated files" not in str(e.value)
137+
assert "Cannot verify validity of the commit: Project metadata is outdated." in str(e.value.stdout)
138+
assert "Run 'renku migrate' command to fix the issue." in str(e.value.stdout)
139+
assert "You are trying to update generated files" not in str(e.value.stdout)
139140

140141

141142
def test_git_pre_commit_hook_in_unsupported_project(unsupported_project):
@@ -148,9 +149,11 @@ def test_git_pre_commit_hook_in_unsupported_project(unsupported_project):
148149
with pytest.raises(git.exc.HookExecutionError) as e:
149150
unsupported_project.repo.index.commit("update project metadata")
150151

151-
assert "Cannot verify validity of the commit: Project was created with a newer version of Renku." in str(e.value)
152-
assert "Upgrade Renku to the latest version." in str(e.value)
153-
assert "You are trying to update generated files" not in str(e.value)
152+
assert "Cannot verify validity of the commit: Project was created with a newer version of Renku." in str(
153+
e.value.stdout
154+
)
155+
assert "Upgrade Renku to the latest version." in str(e.value.stdout)
156+
assert "You are trying to update generated files" not in str(e.value.stdout)
154157

155158

156159
def test_workflow(runner, project):

0 commit comments

Comments
 (0)