Commit db460883 authored by Yannick Jadoul's avatar Yannick Jadoul
Browse files

Convert most of pypy/module/struct/test/test_struct.py to new-style apptest_ tests

--HG--
branch : py3.7
parent 1e937435a7d2
Pipeline #7078 passed with stage
in 4 minutes and 39 seconds
This diff is collapsed.
"""
Tests for the struct module implemented at interp-level in pypy/module/struct.
"""
# spaceconfig = {"usemodules": ["struct", "__pypy__"]}
import struct
from __pypy__ import bytebuffer
def test_pack_into():
b = bytebuffer(19)
sz = struct.calcsize("ii")
struct.pack_into("ii", b, 2, 17, 42)
assert b[:] == (b'\x00' * 2 +
struct.pack("ii", 17, 42) +
b'\x00' * (19-sz-2))
m = memoryview(b)
struct.pack_into("ii", m, 2, 17, 42)
def test_unpack_from():
b = bytebuffer(19)
sz = struct.calcsize("ii")
b[2:2+sz] = struct.pack("ii", 17, 42)
assert struct.unpack_from("ii", b, 2) == (17, 42)
b[:sz] = struct.pack("ii", 18, 43)
assert struct.unpack_from("ii", b) == (18, 43)
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment