Kaydet (Commit) e4857f35 authored tarafından Berker Peksag's avatar Berker Peksag

Issue #6916: Use assertWarns in test_asynchat.

üst 416b516d
...@@ -282,10 +282,10 @@ class TestHelperFunctions(unittest.TestCase): ...@@ -282,10 +282,10 @@ class TestHelperFunctions(unittest.TestCase):
class TestFifo(unittest.TestCase): class TestFifo(unittest.TestCase):
def test_basic(self): def test_basic(self):
with warnings.catch_warnings(record=True) as w: with self.assertWarns(DeprecationWarning) as cm:
f = asynchat.fifo() f = asynchat.fifo()
if w: self.assertEqual(str(cm.warning),
assert issubclass(w[0].category, DeprecationWarning) "fifo class will be removed in Python 3.6")
f.push(7) f.push(7)
f.push(b'a') f.push(b'a')
self.assertEqual(len(f), 2) self.assertEqual(len(f), 2)
...@@ -300,10 +300,10 @@ class TestFifo(unittest.TestCase): ...@@ -300,10 +300,10 @@ class TestFifo(unittest.TestCase):
self.assertEqual(f.pop(), (0, None)) self.assertEqual(f.pop(), (0, None))
def test_given_list(self): 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]) f = asynchat.fifo([b'x', 17, 3])
if w: self.assertEqual(str(cm.warning),
assert issubclass(w[0].category, DeprecationWarning) "fifo class will be removed in Python 3.6")
self.assertEqual(len(f), 3) self.assertEqual(len(f), 3)
self.assertEqual(f.pop(), (1, b'x')) self.assertEqual(f.pop(), (1, b'x'))
self.assertEqual(f.pop(), (1, 17)) self.assertEqual(f.pop(), (1, 17))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment