micropython/tests/basics/deque_slice.py
Dash Peters 7dff38fdc1 py/objdeque: Expand implementation to be doubly-ended and support iter.
Add `pop()`, `appendleft()`, and `extend()` methods, support iteration
and indexing, and initializing from an existing sequence.

Iteration and indexing (subscription) have independent configuration flags
to enable them.  They are enabled by default at the same level that
collections.deque is enabled (the extra features level).

Also add tests for checking new behavior.

Signed-off-by: Damien George <damien@micropython.org>
2024-03-18 14:10:14 +11:00

30 lines
507 B
Python

try:
from collections import deque
except ImportError:
print("SKIP")
raise SystemExit
d = deque((), 10)
d.append(1)
d.append(2)
d.append(3)
# Index slicing for reads is not supported in CPython
try:
d[0:1]
except TypeError:
print("TypeError")
# Index slicing for writes is not supported in CPython
try:
d[0:1] = (-1, -2)
except TypeError:
print("TypeError")
# Index slicing for writes is not supported in CPython
try:
del d[0:1]
except TypeError:
print("TypeError")