tests: Use OBJ_REPR_B compatible mpy file headers.

So these tests can run and pass using OBJ_REPR_B.

Signed-off-by: Jeff Epler <jepler@unpythonic.net>
This commit is contained in:
Jeff Epler
2025-07-15 18:28:55 +01:00
committed by Damien George
parent f6dcf35d5c
commit fca5bbf664
4 changed files with 8 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ SEEK_END = 2
# An mpy file with four constant objects: str, bytes, long-int, float.
test_mpy = (
# header
b"M\x06\x00\x1f" # mpy file header
b"M\x06\x00\x1e" # mpy file header, -msmall-int-bits=30
b"\x06" # n_qstr
b"\x05" # n_obj
# qstrs

View File

@@ -53,11 +53,12 @@ class UserFS:
# these are the test .mpy files
valid_header = bytes([77, 6, mpy_arch, 31])
small_int_bits = 30
valid_header = bytes([77, 6, mpy_arch, small_int_bits])
# fmt: off
user_files = {
# bad architecture (mpy_arch needed for sub-version)
'/mod0.mpy': bytes([77, 6, 0xfc | mpy_arch, 31]),
'/mod0.mpy': bytes([77, 6, 0xfc | mpy_arch, small_int_bits]),
# test loading of viper and asm
'/mod1.mpy': valid_header + (

View File

@@ -6,7 +6,7 @@ if not hasattr(io, "IOBase"):
print("SKIP")
raise SystemExit
# This is the test.py file that is compiled to test.mpy below.
# This is the test.py file that is compiled to test.mpy below. mpy-cross must be invoked with `-msmall-int-bits=30`.
"""
class A:
def __init__(self, arg):
@@ -23,7 +23,7 @@ def f():
x = ("const tuple", None, False, True, 1, 2, 3)
result = 123
"""
file_data = b'M\x06\x00\x1f\x14\x03\x0etest.py\x00\x0f\x02A\x00\x02f\x00\x0cresult\x00/-5#\x82I\x81{\x81w\x82/\x81\x05\x81\x17Iom\x82\x13\x06arg\x00\x05\x1cthis will be a string object\x00\x06\x1bthis will be a bytes object\x00\n\x07\x05\x0bconst tuple\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x81\\\x10\n\x01\x89\x07d`T2\x00\x10\x024\x02\x16\x022\x01\x16\x03"\x80{\x16\x04Qc\x02\x81d\x00\x08\x02(DD\x11\x05\x16\x06\x10\x02\x16\x072\x00\x16\x082\x01\x16\t2\x02\x16\nQc\x03`\x1a\x08\x08\x12\x13@\xb1\xb0\x18\x13Qc@\t\x08\t\x12` Qc@\t\x08\n\x12``Qc\x82@ \x0e\x03\x80\x08+)##\x12\x0b\x12\x0c\x12\r\x12\x0e*\x04Y\x12\x0f\x12\x10\x12\x11*\x03Y#\x00\xc0#\x01\xc0#\x02\xc0Qc'
file_data = b'M\x06\x00\x1e\x14\x03\x0etest.py\x00\x0f\x02A\x00\x02f\x00\x0cresult\x00/-5#\x82I\x81{\x81w\x82/\x81\x05\x81\x17Iom\x82\x13\x06arg\x00\x05\x1cthis will be a string object\x00\x06\x1bthis will be a bytes object\x00\n\x07\x05\x0bconst tuple\x00\x01\x02\x03\x07\x011\x07\x012\x07\x013\x81\\\x10\n\x01\x89\x07d`T2\x00\x10\x024\x02\x16\x022\x01\x16\x03"\x80{\x16\x04Qc\x02\x81d\x00\x08\x02(DD\x11\x05\x16\x06\x10\x02\x16\x072\x00\x16\x082\x01\x16\t2\x02\x16\nQc\x03`\x1a\x08\x08\x12\x13@\xb1\xb0\x18\x13Qc@\t\x08\t\x12` Qc@\t\x08\n\x12``Qc\x82@ \x0e\x03\x80\x08+)##\x12\x0b\x12\x0c\x12\r\x12\x0e*\x04Y\x12\x0f\x12\x10\x12\x11*\x03Y#\x00\xc0#\x01\xc0#\x02\xc0Qc'
class File(io.IOBase):

File diff suppressed because one or more lines are too long