jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] i18n_tests: Remove superfluous assertion ......................................................................
[IMPROV] i18n_tests: Remove superfluous assertion
If a method raises an exception, its output can't be compared via `assertEqual` and usually this would lead to the test to error. But if this is then wrapped in an `assertRaises`, it will expect that exception and thus prevent the error. But that requires an exception so that the only way `assertEqual` actually does compare two values will lead to `assertRaises` to fail because no exception was raised.
This also removes any string formatting which would be done after the method call when the call is tested and which is thus never done anyway.
Change-Id: I10690b8bd5d263001ae5b12a331b3b465150ca30 --- M tests/i18n_tests.py 1 file changed, 7 insertions(+), 21 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index aeb214e..89ab7ce 100644 --- a/tests/i18n_tests.py +++ b/tests/i18n_tests.py @@ -279,38 +279,24 @@ """Test wrong parameter length.""" err_msg = 'Length of parameter does not match PLURAL occurrences' with self.assertRaisesRegex(ValueError, err_msg): - self.assertEqual( - i18n.twntranslate('de', 'test-multiple-plurals', (1, 2)) - % {'action': u'Ändere', 'line': u'drei'}, - u'Bot: Ändere drei Zeilen von mehreren Seiten.') + i18n.twntranslate('de', 'test-multiple-plurals', (1, 2))
with self.assertRaisesRegex(ValueError, err_msg): - self.assertEqual( - i18n.twntranslate('de', 'test-multiple-plurals', ["321"]) - % {'action': u'Ändere', 'line': u'dreihunderteinundzwanzig'}, - u'Bot: Ändere dreihunderteinundzwanzig Zeilen von mehreren Seiten.') + i18n.twntranslate('de', 'test-multiple-plurals', ["321"])
def testMultipleNonNumbers(self): """Test error handling for multiple non-numbers.""" with self.assertRaisesRegex(ValueError, "invalid literal for int() with base 10: 'drei'"): - self.assertEqual( - i18n.twntranslate('de', 'test-multiple-plurals', ["drei", "1", 1]) - % {'action': u'Ändere', 'line': u'drei'}, - u'Bot: Ändere drei Zeilen von einer Seite.') + i18n.twntranslate('de', 'test-multiple-plurals', ["drei", "1", 1]) with self.assertRaisesRegex(ValueError, "invalid literal for int() with base 10: 'elf'"): - self.assertEqual( - i18n.twntranslate('de', 'test-multiple-plurals', - {'action': u'Ändere', 'line': "elf", 'page': 2}), - u'Bot: Ändere elf Zeilen von mehreren Seiten.') + i18n.twntranslate('de', 'test-multiple-plurals', + {'action': u'Ändere', 'line': "elf", 'page': 2})
def testAllParametersExist(self): with self.assertRaisesRegex(KeyError, repr(u'line')): # all parameters must be inside twntranslate - self.assertEqual( - i18n.twntranslate('de', 'test-multiple-plurals', - {'line': 1, 'page': 1}) - % {'action': u'Ändere'}, - u'Bot: Ändere 1 Zeile von einer Seite.') + i18n.twntranslate('de', 'test-multiple-plurals', + {'line': 1, 'page': 1}) % {'action': u'Ändere'}
def test_fallback_lang(self): """