mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
For collections.deque() objects, expose the maxlen parameter as a read-only attribute.
This commit is contained in:
parent
060c7f6bba
commit
5bb0f0e072
4 changed files with 36 additions and 1 deletions
|
@ -105,6 +105,16 @@ class TestBasic(unittest.TestCase):
|
|||
d.extendleft(it)
|
||||
self.assertEqual(list(it), [])
|
||||
|
||||
def test_maxlen_attribute(self):
|
||||
self.assertEqual(deque().maxlen, None)
|
||||
self.assertEqual(deque('abc').maxlen, None)
|
||||
self.assertEqual(deque('abc', maxlen=4).maxlen, 4)
|
||||
self.assertEqual(deque('abc', maxlen=2).maxlen, 2)
|
||||
self.assertEqual(deque('abc', maxlen=0).maxlen, 0)
|
||||
with self.assertRaises(AttributeError):
|
||||
d = deque('abc')
|
||||
d.maxlen = 10
|
||||
|
||||
def test_comparisons(self):
|
||||
d = deque('xabc'); d.popleft()
|
||||
for e in [d, deque('abc'), deque('ab'), deque(), list(d)]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue