Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
laggykiller committed Feb 26, 2024
1 parent 2adaefe commit 42c75be
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ctypes
import os
import platform
from tempfile import TemporaryDirectory

import pytest
try:
Expand Down Expand Up @@ -125,13 +126,14 @@ def test_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 = os.path.join(tmpdir, "0.png")
with LottieAnimation.from_file(json_file) as anim:
anim.save_frame(tmppath)
def test_save_frame():
with TemporaryDirectory() as tmpdir:
tmppath = os.path.join(tmpdir, "0.png")
with LottieAnimation.from_file(json_file) as anim:
anim.save_frame(tmppath)

assert os.path.isfile(tmppath)
Image.open(tmppath)
assert os.path.isfile(tmppath)
Image.open(tmppath)

def _test_save_animation(out):
with LottieAnimation.from_file(json_file) as anim:
Expand All @@ -140,17 +142,20 @@ def _test_save_animation(out):
assert os.path.isfile(out)

@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed")
def test_save_animation_apng(tmpdir):
tmppath = os.path.join(tmpdir, "0.apng")
_test_save_animation(tmppath)
def test_save_animation_apng():
with TemporaryDirectory() as tmpdir:
tmppath = os.path.join(tmpdir, "0.apng")
_test_save_animation(tmppath)

@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed")
def test_save_animation_gif(tmpdir):
tmppath = os.path.join(tmpdir, "0.gif")
_test_save_animation(tmppath)
def test_save_animation_gif():
with TemporaryDirectory() as tmpdir:
tmppath = os.path.join(tmpdir, "0.gif")
_test_save_animation(tmppath)

@pytest.mark.skipif(PILLOW_LOADED is False, reason="Pillow not installed")
@pytest.mark.skipif(platform.python_implementation() == "PyPy", reason="Pillow without webp support")
def test_save_animation_webp(tmpdir):
tmppath = os.path.join(tmpdir, "0.webp")
_test_save_animation(tmppath)
def test_save_animation_webp():
with TemporaryDirectory() as tmpdir:
tmppath = os.path.join(tmpdir, "0.webp")
_test_save_animation(tmppath)

0 comments on commit 42c75be

Please sign in to comment.