mirror of
https://github.com/micropython/micropython.git
synced 2025-07-21 21:11:12 +02:00
Some checks are pending
JavaScript code lint and formatting with Biome / eslint (push) Waiting to run
Check code formatting / code-formatting (push) Waiting to run
Check spelling with codespell / codespell (push) Waiting to run
Build docs / build (push) Waiting to run
Check examples / embedding (push) Waiting to run
Package mpremote / build (push) Waiting to run
.mpy file format and tools / test (push) Waiting to run
Build ports metadata / build (push) Waiting to run
cc3200 port / build (push) Waiting to run
esp32 port / build_idf (esp32_build_cmod_spiram_s2) (push) Waiting to run
esp32 port / build_idf (esp32_build_s3_c3) (push) Waiting to run
esp8266 port / build (push) Waiting to run
mimxrt port / build (push) Waiting to run
nrf port / build (push) Waiting to run
powerpc port / build (push) Waiting to run
qemu port / build_and_test_arm (push) Waiting to run
qemu port / build_and_test_rv32 (push) Waiting to run
renesas-ra port / build_renesas_ra_board (push) Waiting to run
rp2 port / build (push) Waiting to run
samd port / build (push) Waiting to run
stm32 port / build_stm32 (stm32_misc_build) (push) Waiting to run
stm32 port / build_stm32 (stm32_nucleo_build) (push) Waiting to run
stm32 port / build_stm32 (stm32_pyb_build) (push) Waiting to run
unix port / minimal (push) Waiting to run
unix port / reproducible (push) Waiting to run
unix port / standard (push) Waiting to run
unix port / standard_v2 (push) Waiting to run
unix port / coverage (push) Waiting to run
unix port / coverage_32bit (push) Waiting to run
unix port / nanbox (push) Waiting to run
unix port / float (push) Waiting to run
unix port / stackless_clang (push) Waiting to run
unix port / float_clang (push) Waiting to run
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
This change allows tuples to be passed as the prefix/suffix argument to the `str.startswith()` and `str.endswith()` methods. The methods will return `True` if the string starts/ends with any of the prefixes/suffixes in the tuple. Also adds full support for the `start` and `end` arguments to both methods for compatibility with CPython. Tests have been updated for the new behaviour. Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
159 lines
3.1 KiB
Python
159 lines
3.1 KiB
Python
# tests for things that are not implemented, or have non-compliant behaviour
|
|
|
|
try:
|
|
import array
|
|
import struct
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
# when super can't find self
|
|
try:
|
|
exec("def f(): super()")
|
|
except SyntaxError:
|
|
print("SyntaxError")
|
|
|
|
# store to exception attribute is not allowed
|
|
try:
|
|
ValueError().x = 0
|
|
except AttributeError:
|
|
print("AttributeError")
|
|
|
|
# array deletion not implemented
|
|
try:
|
|
a = array.array("b", (1, 2, 3))
|
|
del a[1]
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
# slice with step!=1 not implemented
|
|
try:
|
|
a = array.array("b", (1, 2, 3))
|
|
print(a[3:2:2])
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# containment, looking for integer not implemented
|
|
try:
|
|
print(1 in array.array("B", b"12"))
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# uPy raises TypeError, should be ValueError
|
|
try:
|
|
"%c" % b"\x01\x02"
|
|
except (TypeError, ValueError):
|
|
print("TypeError, ValueError")
|
|
|
|
# attributes/subscr not implemented
|
|
try:
|
|
print("{a[0]}".format(a=[1, 2]))
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# str(...) with keywords not implemented
|
|
try:
|
|
str(b"abc", encoding="utf8")
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# str.rsplit(None, n) not implemented
|
|
try:
|
|
"a a a".rsplit(None, 1)
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# str subscr with step!=1 not implemented
|
|
try:
|
|
print("abc"[1:2:3])
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# bytes(...) with keywords not implemented
|
|
try:
|
|
bytes("abc", encoding="utf8")
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# bytes subscr with step!=1 not implemented
|
|
try:
|
|
b"123"[0:3:2]
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# tuple load with step!=1 not implemented
|
|
try:
|
|
()[2:3:4]
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# list store with step!=1 not implemented
|
|
try:
|
|
[][2:3:4] = []
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# list delete with step!=1 not implemented
|
|
try:
|
|
del [][2:3:4]
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
# struct pack with too many args, not checked by uPy
|
|
print(struct.pack("bb", 1, 2, 3))
|
|
|
|
# struct pack with too few args, not checked by uPy
|
|
print(struct.pack("bb", 1))
|
|
|
|
# array slice assignment with unsupported RHS
|
|
try:
|
|
bytearray(4)[0:1] = [1, 2]
|
|
except NotImplementedError:
|
|
print("NotImplementedError")
|
|
|
|
|
|
# can't assign attributes to a function
|
|
def f():
|
|
pass
|
|
|
|
|
|
try:
|
|
f.x = 1
|
|
except AttributeError:
|
|
print("AttributeError")
|
|
|
|
# can't call a function type (ie make new instances of a function)
|
|
try:
|
|
type(f)()
|
|
except TypeError:
|
|
print("TypeError")
|
|
|
|
|
|
# test when object explicitly listed at not-last position in parent tuple
|
|
# this is not compliant with CPython because of illegal MRO
|
|
class A:
|
|
def foo(self):
|
|
print("A.foo")
|
|
|
|
|
|
class B(object, A):
|
|
pass
|
|
|
|
|
|
B().foo()
|
|
|
|
|
|
# can't assign property (or other special accessors) to already-subclassed class
|
|
class A:
|
|
pass
|
|
|
|
|
|
class B(A):
|
|
pass
|
|
|
|
|
|
try:
|
|
A.bar = property()
|
|
except AttributeError:
|
|
print("AttributeError")
|