Skip to content

Commit

Permalink
Add hypothesis-based test to check crop_positions
Browse files Browse the repository at this point in the history
  • Loading branch information
leblancfg committed Aug 3, 2022
1 parent b35257b commit 4d88b90
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_autocrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4d88b90

Please sign in to comment.