[Python-checkins] cpython: Issue19995: fixed typo; switched from test.support.check_warnings to assertWarns

ethan.furman python-checkins at python.org
Sun Jan 12 17:42:30 CET 2014


http://hg.python.org/cpython/rev/cc8b21988efb
changeset:   88426:cc8b21988efb
parent:      88424:73781fe1daa2
user:        Ethan Furman <ethan at stoneleaf.us>
date:        Sun Jan 12 08:42:35 2014 -0800
summary:
  Issue19995: fixed typo; switched from test.support.check_warnings to assertWarns

files:
  Lib/test/test_unicode.py |  20 +++++---------------
  Objects/unicodeobject.c  |   4 ++--
  2 files changed, 7 insertions(+), 17 deletions(-)


diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1139,13 +1139,6 @@
                 self.value = float(value)
             def __int__(self):
                 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)
         letter_m = PsuedoInt(109)
         self.assertEqual('%x' % 42, '2a')
@@ -1156,14 +1149,11 @@
         self.assertEqual('%X' % letter_m, '6D')
         self.assertEqual('%o' % letter_m, '155')
         self.assertEqual('%c' % letter_m, 'm')
-        for mod, value in (
-                ('%x', pi),
-                ('%x', 3.14),
-                ('%X', 2.11),
-                ('%o', 1.79),
-                ('%c', pi),
-                ):
-            check_depr(mod, value)
+        self.assertWarns(DeprecationWarning, '%x'.__mod__, pi),
+        self.assertWarns(DeprecationWarning, '%x'.__mod__, 3.14),
+        self.assertWarns(DeprecationWarning, '%X'.__mod__, 2.11),
+        self.assertWarns(DeprecationWarning, '%o'.__mod__, 1.79),
+        self.assertWarns(DeprecationWarning, '%c'.__mod__, pi),
 
     def test_formatting_with_enum(self):
         # issue18780
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14005,7 +14005,7 @@
         goto wrongtype;
 
     /* 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 (type == 'o' || type == 'x' || type == 'X') {
             iobj = PyNumber_Index(v);
@@ -14103,7 +14103,7 @@
         PyObject *iobj;
         long x;
         /* 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)) {
             iobj = PyNumber_Index(v);
             if (iobj == NULL) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list