Issue19995: fixed typo; switched from test.support.check_warnings to assertWarns

This commit is contained in:
Ethan Furman 2014-01-12 08:42:35 -08:00
parent 61dab6e3fa
commit a70805e1fa
2 changed files with 7 additions and 17 deletions

View File

@ -1139,13 +1139,6 @@ class UnicodeTest(string_tests.CommonTest,
self.value = float(value) self.value = float(value)
def __int__(self): def __int__(self):
return int(self.value) return int(self.value)
def check_depr(modifier, value):
with support.check_warnings(
("", DeprecationWarning),
quiet=False,
):
warnings.simplefilter('always')
modifier % value
pi = PsuedoFloat(3.1415) pi = PsuedoFloat(3.1415)
letter_m = PsuedoInt(109) letter_m = PsuedoInt(109)
self.assertEqual('%x' % 42, '2a') self.assertEqual('%x' % 42, '2a')
@ -1156,14 +1149,11 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual('%X' % letter_m, '6D') self.assertEqual('%X' % letter_m, '6D')
self.assertEqual('%o' % letter_m, '155') self.assertEqual('%o' % letter_m, '155')
self.assertEqual('%c' % letter_m, 'm') self.assertEqual('%c' % letter_m, 'm')
for mod, value in ( self.assertWarns(DeprecationWarning, '%x'.__mod__, pi),
('%x', pi), self.assertWarns(DeprecationWarning, '%x'.__mod__, 3.14),
('%x', 3.14), self.assertWarns(DeprecationWarning, '%X'.__mod__, 2.11),
('%X', 2.11), self.assertWarns(DeprecationWarning, '%o'.__mod__, 1.79),
('%o', 1.79), self.assertWarns(DeprecationWarning, '%c'.__mod__, pi),
('%c', pi),
):
check_depr(mod, value)
def test_formatting_with_enum(self): def test_formatting_with_enum(self):
# issue18780 # issue18780

View File

@ -14005,7 +14005,7 @@ mainformatlong(PyObject *v,
goto wrongtype; goto wrongtype;
/* make sure number is a type of integer */ /* make sure number is a type of integer */
/* if not, issue depracation warning for now */ /* if not, issue deprecation warning for now */
if (!PyLong_Check(v)) { if (!PyLong_Check(v)) {
if (type == 'o' || type == 'x' || type == 'X') { if (type == 'o' || type == 'x' || type == 'X') {
iobj = PyNumber_Index(v); iobj = PyNumber_Index(v);
@ -14103,7 +14103,7 @@ formatchar(PyObject *v)
PyObject *iobj; PyObject *iobj;
long x; long x;
/* make sure number is a type of integer */ /* make sure number is a type of integer */
/* if not, issue depracation warning for now */ /* if not, issue deprecation warning for now */
if (!PyLong_Check(v)) { if (!PyLong_Check(v)) {
iobj = PyNumber_Index(v); iobj = PyNumber_Index(v);
if (iobj == NULL) { if (iobj == NULL) {