libasterix 0.36.1__tar.gz → 0.36.2__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.
- {libasterix-0.36.1 → libasterix-0.36.2}/PKG-INFO +1 -1
- {libasterix-0.36.1 → libasterix-0.36.2}/pyproject.toml +1 -1
- {libasterix-0.36.1 → libasterix-0.36.2}/src/asterix/base.py +3 -1
- {libasterix-0.36.1 → libasterix-0.36.2}/src/libasterix.egg-info/PKG-INFO +1 -1
- {libasterix-0.36.1 → libasterix-0.36.2}/tests/test_asterix.py +25 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/LICENSE +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/README.md +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/setup.cfg +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/asterix/__init__.py +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/asterix/generated.py +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/asterix/py.typed +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/libasterix.egg-info/SOURCES.txt +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/libasterix.egg-info/dependency_links.txt +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/libasterix.egg-info/requires.txt +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/src/libasterix.egg-info/top_level.txt +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/tests/test_bitstring.py +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/tests/test_mypy.py +0 -0
- {libasterix-0.36.1 → libasterix-0.36.2}/tests/test_raw_datablock.py +0 -0
|
@@ -576,7 +576,9 @@ class Spare(ItemBase):
|
|
|
576
576
|
return cls._parse(bs)
|
|
577
577
|
|
|
578
578
|
@classmethod
|
|
579
|
-
def create(cls, arg: int) -> 'Spare':
|
|
579
|
+
def create(cls, arg: Union['Spare', int]) -> 'Spare':
|
|
580
|
+
if isinstance(arg, Spare):
|
|
581
|
+
return arg
|
|
580
582
|
bs = Bits.from_uinteger(arg, cls.cv_bit_offset8, cls.cv_bit_size)
|
|
581
583
|
return cls(bs)
|
|
582
584
|
|
|
@@ -7,6 +7,7 @@ from typing import *
|
|
|
7
7
|
import pytest
|
|
8
8
|
|
|
9
9
|
from . generated import *
|
|
10
|
+
from . import sample_records
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
def test_create() -> None:
|
|
@@ -1163,6 +1164,30 @@ def test_empty() -> None:
|
|
|
1163
1164
|
rec2 = Cat_000_1_0.cv_record.create({})
|
|
1164
1165
|
assert rec2.is_empty()
|
|
1165
1166
|
|
|
1167
|
+
def _test_roundtrip(num_records: int) -> None:
|
|
1168
|
+
"""For each specification and edition, create a few records,
|
|
1169
|
+
encode, decode, expect the same result."""
|
|
1170
|
+
|
|
1171
|
+
def check(Spec: AstCat, r: Record) -> None:
|
|
1172
|
+
records = list([r]*num_records)
|
|
1173
|
+
bs = b''.join([r.unparse().to_bytes() for r in records])
|
|
1174
|
+
if m_name is None:
|
|
1175
|
+
result = Spec.cv_uap.parse(Bits.from_bytes(bs)) # type: ignore
|
|
1176
|
+
else:
|
|
1177
|
+
result = Spec.cv_uap.parse(m_name, Bits.from_bytes(bs)) # type: ignore
|
|
1178
|
+
assert not isinstance(result, ValueError)
|
|
1179
|
+
bs2 = b''.join([r.unparse().to_bytes() for r in result])
|
|
1180
|
+
assert bs2 == bs
|
|
1181
|
+
|
|
1182
|
+
for lst in manifest['CATS'].values(): # type: ignore
|
|
1183
|
+
for Spec in lst:
|
|
1184
|
+
for (m_name, r1, r2) in sample_records(Spec):
|
|
1185
|
+
check(Spec, r1)
|
|
1186
|
+
check(Spec, r2)
|
|
1187
|
+
|
|
1188
|
+
def test_roundtrip() -> None:
|
|
1189
|
+
_test_roundtrip(5)
|
|
1190
|
+
|
|
1166
1191
|
# python specific tests
|
|
1167
1192
|
|
|
1168
1193
|
|
|
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
|