From 4d88b90e852c882397f01222193f847944dde0d2 Mon Sep 17 00:00:00 2001 From: leblancfg Date: Mon, 14 Mar 2022 09:05:34 -0400 Subject: [PATCH] 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",