| 276 | |
| 277 | |
| 278 | def 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 | |
| 313 | def test_validate_whole(): |