mirror of
https://github.com/Zulko/moviepy.git
synced 2021-07-27 01:17:47 +03:00
* Add module docstrings except in FXs * Update flake8 config * Remove 'find_latest_imagemagick_version.py' * Add tests modules docstrings * Don't execute doctests for tests/ modules * Prevent test error in Windows
61 lines
1.4 KiB
Python
61 lines
1.4 KiB
Python
"""TextClip tests."""
|
|
|
|
import pytest
|
|
|
|
from moviepy.utils import close_all_clips
|
|
from moviepy.video.fx.blink import blink
|
|
from moviepy.video.VideoClip import TextClip
|
|
|
|
from tests.test_helper import FONT
|
|
|
|
|
|
def test_list():
|
|
fonts = TextClip.list("font")
|
|
assert isinstance(fonts, list)
|
|
assert isinstance(fonts[0], str)
|
|
|
|
colors = TextClip.list("color")
|
|
assert isinstance(colors, list)
|
|
assert isinstance(colors[0], str)
|
|
assert "blue" in colors
|
|
|
|
|
|
def test_search():
|
|
blues = TextClip.search("blue", "color")
|
|
assert isinstance(blues, list)
|
|
assert isinstance(blues[0], str)
|
|
assert "blue" in blues
|
|
|
|
|
|
def test_duration():
|
|
clip = TextClip("hello world", size=(1280, 720), color="white", font=FONT)
|
|
clip = clip.with_duration(5)
|
|
assert clip.duration == 5
|
|
clip.close()
|
|
|
|
clip2 = clip.fx(blink, duration_on=1, duration_off=1)
|
|
clip2 = clip2.with_duration(5)
|
|
assert clip2.duration == 5
|
|
close_all_clips(locals())
|
|
|
|
|
|
# Moved from tests.py. Maybe we can remove these?
|
|
def test_if_textclip_crashes_in_caption_mode():
|
|
TextClip(
|
|
text="foo",
|
|
color="white",
|
|
size=(640, 480),
|
|
method="caption",
|
|
align="center",
|
|
font_size=25,
|
|
font=FONT,
|
|
).close()
|
|
|
|
|
|
def test_if_textclip_crashes_in_label_mode():
|
|
TextClip(text="foo", method="label", font=FONT).close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pytest.main()
|