Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
micropython/tests/basics/deque2.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
63 lines (52 sloc)
1.01 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tests for deques with "check overflow" flag and other extensions | |
# wrt to CPython. | |
try: | |
from collections import deque | |
except ImportError: | |
print("SKIP") | |
raise SystemExit | |
# Initial sequence is not supported | |
try: | |
deque([1, 2, 3], 10) | |
except ValueError: | |
print("ValueError") | |
# Not even empty list, only empty tuple | |
try: | |
deque([], 10) | |
except ValueError: | |
print("ValueError") | |
# Only fixed-size deques are supported, so length arg is mandatory | |
try: | |
deque(()) | |
except TypeError: | |
print("TypeError") | |
d = deque((), 2, True) | |
try: | |
d.popleft() | |
except IndexError: | |
print("IndexError") | |
print(d.append(1)) | |
print(d.popleft()) | |
d.append(2) | |
print(d.popleft()) | |
d.append(3) | |
d.append(4) | |
print(d.popleft(), d.popleft()) | |
try: | |
d.popleft() | |
except IndexError as e: | |
print(repr(e)) | |
d.append(5) | |
d.append(6) | |
print(len(d)) | |
try: | |
d.append(7) | |
except IndexError as e: | |
print(repr(e)) | |
print(len(d)) | |
print(d.popleft(), d.popleft()) | |
print(len(d)) | |
try: | |
d.popleft() | |
except IndexError as e: | |
print(repr(e)) |