]> granicus.if.org Git - python/commitdiff
Issue #6916: Use assertWarns in test_asynchat.
authorBerker Peksag <berker.peksag@gmail.com>
Wed, 9 Jul 2014 00:12:23 +0000 (03:12 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Wed, 9 Jul 2014 00:12:23 +0000 (03:12 +0300)
Lib/test/test_asynchat.py

index 9e305731ed36a4f505c893078b7e18414ac39bbd..fd64adc460d9909c23395494f4b7b2b2af9480f4 100644 (file)
@@ -282,10 +282,10 @@ class TestHelperFunctions(unittest.TestCase):
 
 class TestFifo(unittest.TestCase):
     def test_basic(self):
-        with warnings.catch_warnings(record=True) as w:
+        with self.assertWarns(DeprecationWarning) as cm:
             f = asynchat.fifo()
-            if w:
-                assert issubclass(w[0].category, DeprecationWarning)
+        self.assertEqual(str(cm.warning),
+                         "fifo class will be removed in Python 3.6")
         f.push(7)
         f.push(b'a')
         self.assertEqual(len(f), 2)
@@ -300,10 +300,10 @@ class TestFifo(unittest.TestCase):
         self.assertEqual(f.pop(), (0, None))
 
     def test_given_list(self):
-        with warnings.catch_warnings(record=True) as w:
+        with self.assertWarns(DeprecationWarning) as cm:
             f = asynchat.fifo([b'x', 17, 3])
-            if w:
-                assert issubclass(w[0].category, DeprecationWarning)
+        self.assertEqual(str(cm.warning),
+                         "fifo class will be removed in Python 3.6")
         self.assertEqual(len(f), 3)
         self.assertEqual(f.pop(), (1, b'x'))
         self.assertEqual(f.pop(), (1, 17))