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

Method test_min_length

tests/unit/test_constraints.py:447–459  ·  view source on GitHub ↗
(self, proto)

Source from the content-addressed store, hash-verified

445
446class TestStrConstraints:
447 def test_min_length(self, proto):
448 class Ex(msgspec.Struct):
449 x: Annotated[str, Meta(min_length=2)]
450
451 dec = proto.Decoder(Ex)
452
453 for x in ["xx", "xxx", "𝄞x"]:
454 assert dec.decode(proto.encode(Ex(x))).x == x
455
456 err_msg = r"Expected `str` of length >= 2 - at `\$.x`"
457 for x in ["x", "𝄞", ""]:
458 with pytest.raises(msgspec.ValidationError, match=err_msg):
459 dec.decode(proto.encode(Ex(x)))
460
461 def test_max_length(self, proto):
462 class Ex(msgspec.Struct):

Callers

nothing calls this directly

Calls 2

decodeMethod · 0.80
ExClass · 0.70

Tested by

no test coverage detected