class User(Message): name: str = String(number=1)
class UserV2(Message): name: str = String(number=1) x: int = Int32(number=2)
def test_invalid_input(self, invalid_input): with pytest.raises(ValueError): String(number=1).validate_value(invalid_input)
def test_valid_input(self, valid_input): String(number=1).validate_value(valid_input)
def test_decode(self, value, expected_value): stream = io.BytesIO(value) assert String(number=1).decode(stream) == expected_value
def test_encode(self, value, expected_value): assert String(number=1).encode_value(value) == expected_value