mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
test_locale now ignores the DeprecationWarning (#977)
Don't fail anymore if test run with python3 -Werror. Fix also deprecation message: add a space.
This commit is contained in:
parent
734125938d
commit
9acc6a03f1
2 changed files with 14 additions and 12 deletions
|
@ -1,4 +1,4 @@
|
|||
from test.support import verbose, is_android
|
||||
from test.support import verbose, is_android, check_warnings
|
||||
import unittest
|
||||
import locale
|
||||
import sys
|
||||
|
@ -144,8 +144,9 @@ class BaseFormattingTest(object):
|
|||
func(format, value, **format_opts), out)
|
||||
|
||||
def _test_format(self, format, value, out, **format_opts):
|
||||
self._test_formatfunc(format, value, out,
|
||||
func=locale.format, **format_opts)
|
||||
with check_warnings(('', DeprecationWarning)):
|
||||
self._test_formatfunc(format, value, out,
|
||||
func=locale.format, **format_opts)
|
||||
|
||||
def _test_format_string(self, format, value, out, **format_opts):
|
||||
self._test_formatfunc(format, value, out,
|
||||
|
@ -232,14 +233,15 @@ class TestFormatPatternArg(unittest.TestCase):
|
|||
# Test handling of pattern argument of format
|
||||
|
||||
def test_onlyOnePattern(self):
|
||||
# Issue 2522: accept exactly one % pattern, and no extra chars.
|
||||
self.assertRaises(ValueError, locale.format, "%f\n", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f\r", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f\r\n", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, " %f", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%fg", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%^g", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f%%", 'foo')
|
||||
with check_warnings(('', DeprecationWarning)):
|
||||
# Issue 2522: accept exactly one % pattern, and no extra chars.
|
||||
self.assertRaises(ValueError, locale.format, "%f\n", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f\r", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f\r\n", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, " %f", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%fg", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%^g", 'foo')
|
||||
self.assertRaises(ValueError, locale.format, "%f%%", 'foo')
|
||||
|
||||
|
||||
class TestLocaleFormatString(unittest.TestCase):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue