(self, proto)
| 4426 | proto.decode(msg, type=typ, strict=False) |
| 4427 | |
| 4428 | def test_lax_int_enum(self, proto): |
| 4429 | class Ex(enum.IntEnum): |
| 4430 | x = 1 |
| 4431 | y = -2 |
| 4432 | |
| 4433 | def roundtrip(msg): |
| 4434 | return proto.decode(proto.encode(msg), type=Ex, strict=False) |
| 4435 | |
| 4436 | assert roundtrip("1") is Ex.x |
| 4437 | assert roundtrip("-2") is Ex.y |
| 4438 | with pytest.raises(ValidationError, match="Invalid enum value 3"): |
| 4439 | roundtrip("3") |
| 4440 | with pytest.raises(ValidationError, match="Expected `int`, got `str`"): |
| 4441 | roundtrip("A") |
| 4442 | |
| 4443 | def test_lax_int_literal(self, proto): |
| 4444 | typ = Literal[1, -2] |
nothing calls this directly
no test coverage detected