MCPcopy
hub / github.com/pydantic/pydantic / test_deque_validation

Function test_deque_validation

tests/test_validators.py:278–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

276
277
278def test_deque_validation():
279 class Model(BaseModel):
280 a: deque[int]
281
282 with pytest.raises(ValidationError) as exc_info:
283 Model(a='snap')
284 assert exc_info.value.errors(include_url=False) == [
285 {'type': 'list_type', 'loc': ('a',), 'msg': 'Input should be a valid list', 'input': 'snap'}
286 ]
287 with pytest.raises(ValidationError) as exc_info:
288 Model(a=['a'])
289 assert exc_info.value.errors(include_url=False) == [
290 {
291 'type': 'int_parsing',
292 'loc': ('a', 0),
293 'msg': 'Input should be a valid integer, unable to parse string as an integer',
294 'input': 'a',
295 }
296 ]
297 with pytest.raises(ValidationError) as exc_info:
298 Model(a=('a',))
299 assert exc_info.value.errors(include_url=False) == [
300 {
301 'type': 'int_parsing',
302 'loc': ('a', 0),
303 'msg': 'Input should be a valid integer, unable to parse string as an integer',
304 'input': 'a',
305 }
306 ]
307
308 assert Model(a={'1'}).a == deque([1])
309 assert Model(a=[4, 5]).a == deque([4, 5])
310 assert Model(a=(6,)).a == deque([6])
311
312
313def test_validate_whole():

Callers

nothing calls this directly

Calls 2

ModelClass · 0.70
errorsMethod · 0.45

Tested by

no test coverage detected