#6916: raise a deprecation warning if using asynchat.fifo
This commit is contained in:
parent
892051af95
commit
bd0487694c
|
@ -275,6 +275,9 @@ class simple_producer:
|
|||
|
||||
class fifo:
|
||||
def __init__ (self, list=None):
|
||||
import warnings
|
||||
warnings.warn('fifo class will be removed in Python 3.6',
|
||||
DeprecationWarning, stacklevel=2)
|
||||
if not list:
|
||||
self.list = deque()
|
||||
else:
|
||||
|
|
|
@ -8,6 +8,7 @@ thread = support.import_module('_thread')
|
|||
import asyncore, asynchat, socket, time
|
||||
import unittest
|
||||
import sys
|
||||
import warnings
|
||||
try:
|
||||
import threading
|
||||
except ImportError:
|
||||
|
@ -260,7 +261,9 @@ class TestHelperFunctions(unittest.TestCase):
|
|||
|
||||
class TestFifo(unittest.TestCase):
|
||||
def test_basic(self):
|
||||
f = asynchat.fifo()
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
f = asynchat.fifo()
|
||||
assert issubclass(w[0].category, DeprecationWarning)
|
||||
f.push(7)
|
||||
f.push(b'a')
|
||||
self.assertEqual(len(f), 2)
|
||||
|
@ -275,7 +278,9 @@ class TestFifo(unittest.TestCase):
|
|||
self.assertEqual(f.pop(), (0, None))
|
||||
|
||||
def test_given_list(self):
|
||||
f = asynchat.fifo([b'x', 17, 3])
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
f = asynchat.fifo([b'x', 17, 3])
|
||||
assert issubclass(w[0].category, DeprecationWarning)
|
||||
self.assertEqual(len(f), 3)
|
||||
self.assertEqual(f.pop(), (1, b'x'))
|
||||
self.assertEqual(f.pop(), (1, 17))
|
||||
|
|
Loading…
Reference in New Issue