Skip to content

Commit 9d8fdc4

Browse files
committed
Issue #6916: Use assertWarns in test_asynchat.
1 parent c7244bc commit 9d8fdc4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Lib/test/test_asynchat.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ def test_find_prefix_at_end(self):
282282

283283
class TestFifo(unittest.TestCase):
284284
def test_basic(self):
285-
with warnings.catch_warnings(record=True) as w:
285+
with self.assertWarns(DeprecationWarning) as cm:
286286
f = asynchat.fifo()
287-
if w:
288-
assert issubclass(w[0].category, DeprecationWarning)
287+
self.assertEqual(str(cm.warning),
288+
"fifo class will be removed in Python 3.6")
289289
f.push(7)
290290
f.push(b'a')
291291
self.assertEqual(len(f), 2)
@@ -300,10 +300,10 @@ def test_basic(self):
300300
self.assertEqual(f.pop(), (0, None))
301301

302302
def test_given_list(self):
303-
with warnings.catch_warnings(record=True) as w:
303+
with self.assertWarns(DeprecationWarning) as cm:
304304
f = asynchat.fifo([b'x', 17, 3])
305-
if w:
306-
assert issubclass(w[0].category, DeprecationWarning)
305+
self.assertEqual(str(cm.warning),
306+
"fifo class will be removed in Python 3.6")
307307
self.assertEqual(len(f), 3)
308308
self.assertEqual(f.pop(), (1, b'x'))
309309
self.assertEqual(f.pop(), (1, 17))

0 commit comments

Comments
 (0)