MCPcopy Index your code
hub / github.com/msgspec/msgspec / test_time_constrs

Method test_time_constrs

tests/unit/test_convert.py:609–622  ·  view source on GitHub ↗
(self, as_str)

Source from the content-addressed store, hash-verified

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
625class TestDate:

Callers

nothing calls this directly

Calls 1

ExClass · 0.70

Tested by

no test coverage detected