summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2023-10-14 06:07:02 (GMT)
committerGitHub <noreply@github.com>2023-10-14 06:07:02 (GMT)
commit38bd2c520a2df7904e32093da2166eec2c039802 (patch)
tree38c31ad1a4b3ec189658ccc9023520df6912f88e /Lib/test
parent45cfabb8429b5ecee78ca60c1ca8f7f5820afc5c (diff)
downloadcpython-38bd2c520a2df7904e32093da2166eec2c039802.zip
cpython-38bd2c520a2df7904e32093da2166eec2c039802.tar.gz
cpython-38bd2c520a2df7904e32093da2166eec2c039802.tar.bz2
gh-88434: Emit deprecation warnings for non-integer numbers in gettext if translation not found (GH-110574)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_gettext.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index dd33b9b..b2fe3e2 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -332,22 +332,24 @@ class PluralFormsTests:
x = gettext(singular)
self.assertEqual(x, tsingular)
+ lineno = self._test_plural_forms.__code__.co_firstlineno + 12
+ with self.assertWarns(DeprecationWarning) as cm:
+ x = ngettext(singular, plural, 1.0)
+ self.assertEqual(cm.filename, __file__)
+ self.assertEqual(cm.lineno, lineno)
+ self.assertEqual(x, tsingular)
+ with self.assertWarns(DeprecationWarning) as cm:
+ x = ngettext(singular, plural, 1.1)
+ self.assertEqual(cm.filename, __file__)
+ self.assertEqual(cm.lineno, lineno + 5)
+ self.assertEqual(x, tplural)
+
if numbers_only:
- lineno = self._test_plural_forms.__code__.co_firstlineno + 9
- with self.assertWarns(DeprecationWarning) as cm:
- x = ngettext(singular, plural, 1.0)
- self.assertEqual(cm.filename, __file__)
- self.assertEqual(cm.lineno, lineno + 4)
- self.assertEqual(x, tsingular)
- with self.assertWarns(DeprecationWarning) as cm:
- x = ngettext(singular, plural, 1.1)
- self.assertEqual(cm.filename, __file__)
- self.assertEqual(cm.lineno, lineno + 9)
- self.assertEqual(x, tplural)
with self.assertRaises(TypeError):
ngettext(singular, plural, None)
else:
- x = ngettext(singular, plural, None)
+ with self.assertWarns(DeprecationWarning) as cm:
+ x = ngettext(singular, plural, None)
self.assertEqual(x, tplural)
def test_plural_forms(self):