XZise has uploaded a new change for review. https://gerrit.wikimedia.org/r/231967
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 which is tested and which is thus never done anyway. Change-Id: I10690b8bd5d263001ae5b12a331b3b465150ca30 --- M tests/i18n_tests.py 1 file changed, 7 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/67/231967/1 diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index aeb214e..c2caabd 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}) def test_fallback_lang(self): """ -- To view, visit https://gerrit.wikimedia.org/r/231967 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I10690b8bd5d263001ae5b12a331b3b465150ca30 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits