Skip to content

Commit

Permalink
Test angle by function
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jan 23, 2021
1 parent 487447b commit fae2948
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/test_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ def test_resize():
None,
[["ABC", "ABC", "ABC", "ABC"], ["DEA", "CDE", "BCD", "ABC"]],
),
(
lambda t: 90,
None,
None,
None,
[["ABC", "ABC", "ABC", "ABC"], ["DEA", "CDE", "BCD", "ABC"]],
),
(
180,
None,
Expand Down Expand Up @@ -584,8 +591,12 @@ def test_rotate(

# angles are defined in degrees, so convert to radians testing ``unit="rad"``
if unit == "rad":
angle = math.radians(angle)

if hasattr(angle, "__call__"):
_angle = lambda t: math.radians(angle(0))
else:
_angle = math.radians(angle)
else:
_angle = angle
clip = BitmapClip(original_frames, fps=1)

kwargs = {
Expand All @@ -597,13 +608,13 @@ def test_rotate(
}
if resample not in ["bilinear", "nearest", "bicubic"]:
with pytest.raises(ValueError) as exc:
clip.rotate(angle, **kwargs)
clip.rotate(_angle, **kwargs)
assert (
"'resample' argument must be either 'bilinear', 'nearest' or 'bicubic'"
) == str(exc.value)
return
else:
rotated_clip = clip.rotate(angle, **kwargs)
rotated_clip = clip.rotate(_angle, **kwargs)

expected_clip = BitmapClip(expected_frames, fps=1)
assert rotated_clip.to_bitmap() == expected_clip.to_bitmap()
Expand Down

0 comments on commit fae2948

Please sign in to comment.