diff --git a/requirements-dev.txt b/requirements-dev.txt index 7b455f4..181c323 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,5 @@ tox portray wheel twine +hypothesis -r requirements.txt diff --git a/tests/test_autocrop.py b/tests/test_autocrop.py index c544dd8..a6f9aad 100644 --- a/tests/test_autocrop.py +++ b/tests/test_autocrop.py @@ -3,9 +3,10 @@ from glob import glob import shutil -import pytest # noqa: F401 +import pytest import cv2 import numpy as np +from hypothesis import given, example, strategies as st from autocrop.autocrop import gamma, Cropper @@ -77,6 +78,14 @@ def test_adjust_boundaries(values, expected_result): assert result == expected_result +@given(*[st.integers(min_value=0, max_value=500)] * 4) +@example(13, 280, 26, 33) +def test_crop_positions(x, y, w, h): + c = Cropper() + result = c._crop_positions(500, 500, x, y, w, h) + assert all(pos >= 0 for pos in result) + + @pytest.mark.slow @pytest.mark.parametrize( "height, width",