MCPcopy
hub / github.com/msgspec/msgspec / test_int_constr_bounds

Method test_int_constr_bounds

tests/unit/test_convert.py:343–355  ·  view source on GitHub ↗
(self, name, bound, good, bad)

Source from the content-addressed store, hash-verified

341 ],
342 )
343 def test_int_constr_bounds(self, name, bound, good, bad):
344 class Ex(Struct):
345 x: Annotated[int, Meta(**{name: bound})]
346
347 for x in good:
348 assert convert({"x": x}, Ex).x == x
349
350 op = ">=" if name.startswith("g") else "<="
351 offset = {"lt": -1, "gt": 1}.get(name, 0)
352 err_msg = rf"Expected `int` {op} {bound + offset} - at `\$.x`"
353 for x in bad:
354 with pytest.raises(ValidationError, match=err_msg):
355 convert({"x": x}, Ex)
356
357 def test_int_constr_multiple_of(self):
358 class Ex(Struct):

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected