From 4d88b90e852c882397f01222193f847944dde0d2 Mon Sep 17 00:00:00 2001 From: leblancfg Date: Mon, 14 Mar 2022 09:05:34 -0400 Subject: [PATCH 1/2] Add hypothesis-based test to check crop_positions --- tests/test_autocrop.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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", From 5acbf02538147a40a5f641ebbe08fe6006fb0dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leblanc?= Date: Mon, 14 Mar 2022 12:34:33 -0400 Subject: [PATCH 2/2] Add hypothesis to dev requirements --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) 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