| 607 | |
| 608 | @pytest.mark.parametrize("as_str", [False, True]) |
| 609 | def test_time_constrs(self, as_str): |
| 610 | class Ex(Struct): |
| 611 | x: Annotated[datetime.time, Meta(tz=True)] |
| 612 | |
| 613 | builtin_types = None if as_str else (datetime.time,) |
| 614 | |
| 615 | aware = Ex(datetime.time(12, 34, tzinfo=UTC)) |
| 616 | aware_msg = to_builtins(aware, builtin_types=builtin_types) |
| 617 | naive = Ex(datetime.time(12, 34)) |
| 618 | naive_msg = to_builtins(naive, builtin_types=builtin_types) |
| 619 | |
| 620 | assert convert(aware_msg, Ex) == aware |
| 621 | with pytest.raises(ValidationError): |
| 622 | convert(naive_msg, Ex) |
| 623 | |
| 624 | |
| 625 | class TestDate: |