-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_image.py
More file actions
29 lines (22 loc) · 850 Bytes
/
test_image.py
File metadata and controls
29 lines (22 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from hypothesis import given
import hypothesis.strategies as st
from pygexml.strategies import st_images
from pygexml.image import Image
def test_image_example() -> None:
image = Image(filename="a.jpg", width=800, height=600)
assert image.filename == "a.jpg"
assert image.width == 800
assert image.height == 600
@given(
st.text(),
st.one_of(st.none(), st.integers(min_value=1)),
st.one_of(st.none(), st.integers(min_value=1)),
)
def test_image_arbitrary(filename: str, width: int, height: int) -> None:
image = Image(filename=filename, width=width, height=height)
assert image.filename == filename
assert image.width == width
assert image.height == height
@given(st_images)
def test_image_serialization_roundtrip_arbitrary(image: Image) -> None:
assert Image.from_dict(image.to_dict()) == image