From c5f04a1bb05418b7624c151105c2263ce948dd83 Mon Sep 17 00:00:00 2001 From: laggykiller Date: Tue, 27 Feb 2024 00:52:31 +0800 Subject: [PATCH] Fix test for i686 --- .github/workflows/build.yml | 3 ++- tests/test_all.py | 24 +++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 190f3a7..bdfb76a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,8 @@ jobs: CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_archs_windows }} CIBW_ARCHS_MACOS: ${{ matrix.cibw_archs_macos }} CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux }} - CIBW_TEST_REQUIRES: pytest Pillow + CIBW_TEST_REQUIRES: pytest + CIBW_BEFORE_TEST: pip install --prefer-binary Pillow CIBW_TEST_COMMAND: pytest {package}/tests # If enable stubgen (pyproject.toml), then requires mypy which depends on typed-ast # typed-ast cannot run on pypy <3.8 diff --git a/tests/test_all.py b/tests/test_all.py index 69ffc09..0285aeb 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -2,7 +2,14 @@ import ctypes from pathlib import Path -from PIL import Image +import pytest +try: + from PIL import Image + + PILLOW_LOADED = True +except ModuleNotFoundError: + PILLOW_LOADED = False + from rlottie_python import LottieAnimation from rlottie_python.rlottiecommon import LOTLayerNode @@ -109,12 +116,14 @@ def test_lottie_configure_model_cache_size(): with LottieAnimation.from_file(json_file) as anim: anim.lottie_configure_model_cache_size(0) +@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed") def test_render_pillow_frame(): with LottieAnimation.from_file(json_file) as anim: im = anim.render_pillow_frame() assert isinstance(im, Image.Image) - + +@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed") def test_save_frame(tmpdir): tmppath = Path(tmpdir, "0.png").as_posix() with LottieAnimation.from_file(json_file) as anim: @@ -123,13 +132,14 @@ def test_save_frame(tmpdir): assert Path(tmppath).is_file() Image.open(tmppath) -def _test_save_animation(out): - with LottieAnimation.from_file(json_file) as anim: - anim.save_frame(out) +@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed") +def test_save_animation(tmpdir): + def _test_save_animation(out): + with LottieAnimation.from_file(json_file) as anim: + anim.save_frame(out) - assert Path(out).is_file() + assert Path(out).is_file() -def test_save_animation(tmpdir): for i in ("0.apng", "0.gif", "0.webp"): tmppath = Path(tmpdir, i).as_posix() _test_save_animation(tmppath) \ No newline at end of file