Skip to content

Commit

Permalink
Update the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontagu committed Jan 30, 2024
1 parent b9408e5 commit 06ee4c9
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions tests/test_types.py
Expand Up @@ -4481,11 +4481,28 @@ def test_bytesize_raises():
class Model(BaseModel):
size: ByteSize

with pytest.raises(ValidationError, match='parse value'):
with pytest.raises(ValidationError, match='parse value') as exc_info:
Model(size='d1MB')
assert exc_info.value.errors(include_url=False) == [
{
'input': 'd1MB',
'loc': ('size',),
'msg': 'could not parse value and unit from byte string',
'type': 'byte_size',
}
]

with pytest.raises(ValidationError, match='byte unit'):
with pytest.raises(ValidationError, match='byte unit') as exc_info:
Model(size='1LiB')
assert exc_info.value.errors(include_url=False) == [
{
'ctx': {'unit': 'LiB'},
'input': '1LiB',
'loc': ('size',),
'msg': 'could not interpret byte unit: LiB',
'type': 'byte_size_unit',
}
]

# 1Gi is not a valid unit unlike 1G
with pytest.raises(ValidationError, match='byte unit'):
Expand Down

0 comments on commit 06ee4c9

Please sign in to comment.