Skip to content

Commit 907a1c5

Browse files
committed
add test
1 parent 1406cd4 commit 907a1c5

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ classifiers = [
1919
"Programming Language :: Python :: Implementation :: CPython",
2020
"Programming Language :: Python :: Implementation :: PyPy",
2121
]
22+
dependencies = []
2223

2324
[project.urls]
2425
Homepage = "https://msgpack.org/"
@@ -43,3 +44,9 @@ lint.select = [
4344
"I", # isort
4445
#"UP", pyupgrade
4546
]
47+
48+
[dependency-groups]
49+
dev = [
50+
"cython>=3.2.5",
51+
"pytest>=9.0.3",
52+
]

test/test_extension.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
def test_pack_ext_type():
88
def p(s):
9-
packer = msgpack.Packer()
9+
packer = msgpack.Packer(autoreset=False)
1010
packer.pack_ext_type(0x42, s)
1111
return packer.bytes()
1212

@@ -20,6 +20,15 @@ def p(s):
2020
assert p(b"A" * 0x00012345) == b"\xc9\x00\x01\x23\x45\x42" + b"A" * 0x00012345 # ext 32
2121

2222

23+
def test_pack_ext_type_autoreset():
24+
packer = msgpack.Packer()
25+
26+
assert packer.pack_ext_type(0x42, b"A") == b"\xd4\x42A"
27+
assert packer.bytes() == b""
28+
assert packer.pack_ext_type(0x42, b"ABC") == b"\xc7\x03\x42ABC"
29+
assert packer.bytes() == b""
30+
31+
2332
def test_unpack_ext_type():
2433
def check(b, expected):
2534
assert msgpack.unpackb(b) == expected

0 commit comments

Comments
 (0)