[fix] fix all tests that weren't formatting translated strings correctly

This commit is contained in:
Laurent Peuch 2019-07-28 21:38:37 +02:00
parent 737f2dd967
commit 69b0d496dd

View file

@ -19,7 +19,7 @@ def test_read_file_missing_file():
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
read_file(bad_file) read_file(bad_file)
translation = m18n.g('file_not_exist') translation = m18n.g('file_not_exist', path=bad_file)
expected_msg = translation.format(path=bad_file) expected_msg = translation.format(path=bad_file)
assert expected_msg in str(exception) assert expected_msg in str(exception)
@ -31,7 +31,7 @@ def test_read_file_cannot_read_ioerror(test_file, mocker):
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
read_file(str(test_file)) read_file(str(test_file))
translation = m18n.g('cannot_open_file') translation = m18n.g('cannot_open_file', file=str(test_file), error=error)
expected_msg = translation.format(file=str(test_file), error=error) expected_msg = translation.format(file=str(test_file), error=error)
assert expected_msg in str(exception) assert expected_msg in str(exception)
@ -49,7 +49,7 @@ def test_read_json_cannot_read(test_json, mocker):
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
read_json(str(test_json)) read_json(str(test_json))
translation = m18n.g('corrupted_json') translation = m18n.g('corrupted_json', ressource=str(test_json), error=error)
expected_msg = translation.format(ressource=str(test_json), error=error) expected_msg = translation.format(ressource=str(test_json), error=error)
assert expected_msg in str(exception) assert expected_msg in str(exception)
@ -75,7 +75,7 @@ def test_write_to_existing_file_bad_perms(test_file, mocker):
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
write_to_file(str(test_file), 'yolo\nswag') write_to_file(str(test_file), 'yolo\nswag')
translation = m18n.g('cannot_write_file') translation = m18n.g('cannot_write_file', file=str(test_file), error=error)
expected_msg = translation.format(file=str(test_file), error=error) expected_msg = translation.format(file=str(test_file), error=error)
assert expected_msg in str(exception) assert expected_msg in str(exception)
@ -140,7 +140,7 @@ def test_write_to_json_bad_perms(test_json, mocker):
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
write_to_json(str(test_json), {'a': 1}) write_to_json(str(test_json), {'a': 1})
translation = m18n.g('cannot_write_file') translation = m18n.g('cannot_write_file', file=str(test_json), error=error)
expected_msg = translation.format(file=str(test_json), error=error) expected_msg = translation.format(file=str(test_json), error=error)
assert expected_msg in str(exception) assert expected_msg in str(exception)
@ -163,7 +163,7 @@ def test_remove_file_bad_perms(test_file, mocker):
with pytest.raises(MoulinetteError) as exception: with pytest.raises(MoulinetteError) as exception:
rm(str(test_file)) rm(str(test_file))
translation = m18n.g('error_removing') translation = m18n.g('error_removing', path=str(test_file), error=error)
expected_msg = translation.format(path=str(test_file), error=error) expected_msg = translation.format(path=str(test_file), error=error)
assert expected_msg in str(exception) assert expected_msg in str(exception)