structo 0.0.5__tar.gz → 0.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {structo-0.0.5 → structo-0.0.6}/PKG-INFO +1 -1
- {structo-0.0.5 → structo-0.0.6}/structo/__init__.py +1 -1
- {structo-0.0.5 → structo-0.0.6}/structo/serialise.py +1 -1
- structo-0.0.6/tests/test_object.py +54 -0
- {structo-0.0.5 → structo-0.0.6}/.gitignore +0 -0
- {structo-0.0.5 → structo-0.0.6}/LICENSE +0 -0
- {structo-0.0.5 → structo-0.0.6}/README.md +0 -0
- {structo-0.0.5 → structo-0.0.6}/examples/custom_serializer.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/examples/iterable_serializer.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/examples/wav.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/pyproject.toml +0 -0
- {structo-0.0.5 → structo-0.0.6}/pytest.ini +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/object.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/packed.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/serializer.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/__init__.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/array.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/blob.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/buffer.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/list.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/literal.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/object.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/packed.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/primatives.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/types/string.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/structo/utils.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/tests/test_array.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/tests/test_packed.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/tests/test_primatives.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/tests/test_size.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/tests/utils.py +0 -0
- {structo-0.0.5 → structo-0.0.6}/uv.lock +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from utils import test
|
|
2
|
+
import typing as t
|
|
3
|
+
|
|
4
|
+
import structo as st
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@test("SerialiableObject: object")
|
|
8
|
+
def _():
|
|
9
|
+
class Foo(st.SerializableObject):
|
|
10
|
+
a: t.Annotated[int, st.uint8]
|
|
11
|
+
|
|
12
|
+
obj = Foo(a=1)
|
|
13
|
+
assert obj == Foo.from_bytes(obj.to_bytes())
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@test("SerialiableObject: multiple attributes")
|
|
17
|
+
def _():
|
|
18
|
+
class Foo(st.SerializableObject):
|
|
19
|
+
a: t.Annotated[int, st.uint8]
|
|
20
|
+
b: t.Annotated[int, st.uint16_BE]
|
|
21
|
+
|
|
22
|
+
obj = Foo(a=1, b=256)
|
|
23
|
+
assert obj == Foo.from_bytes(obj.to_bytes())
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@test("SerialiableObject: sizeof")
|
|
27
|
+
def _():
|
|
28
|
+
|
|
29
|
+
class Foo(st.SerializableObject):
|
|
30
|
+
a: t.Annotated[int, st.uint8]
|
|
31
|
+
b: t.Annotated[str, st.uint8]
|
|
32
|
+
|
|
33
|
+
assert Foo.sizeof() == 2
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@test("SerialiableObject: sizeof unknowable")
|
|
37
|
+
def _():
|
|
38
|
+
class Foo(st.SerializableObject):
|
|
39
|
+
a: t.Annotated[int, st.uint8]
|
|
40
|
+
b: t.Annotated[str, st.String(st.uint8)]
|
|
41
|
+
|
|
42
|
+
assert Foo.sizeof() is None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@test("SerialiableObject: nested object")
|
|
46
|
+
def _():
|
|
47
|
+
class Foo(st.SerializableObject):
|
|
48
|
+
a: t.Annotated[int, st.uint8]
|
|
49
|
+
|
|
50
|
+
class Bar(st.SerializableObject):
|
|
51
|
+
foo: Foo
|
|
52
|
+
|
|
53
|
+
obj = Bar(foo=Foo(1))
|
|
54
|
+
assert obj == Bar.from_bytes(obj.to_bytes())
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|