Skip to content

Commit

Permalink
Make TextClip tests work on Travis CI (#747)
Browse files Browse the repository at this point in the history
Added a line into .travis.yml to modify the ImageMagick policy file, then uncommented all the tests that had been temporarily removed.
  • Loading branch information
tburrows13 authored Mar 30, 2018
1 parent 6cbd4f3 commit 554e069
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 31 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ before_install:
- pip install --upgrade setuptools
# The default py that is installed is too old on some platforms, leading to version conflicts
- pip install --upgrade py pytest

# modify ImageMagick policy file so that Textclips work correctly.
# `| sudo tee` replaces `>` so that it can have root permissions
- cat /etc/ImageMagick/policy.xml | sed 's/none/read,write/g' | sudo tee /etc/ImageMagick/policy.xml

install:
- echo "No install action required. Implicitly performed by the testing."
Expand Down
8 changes: 1 addition & 7 deletions tests/test_PR.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


sys.path.append("tests")
from test_helper import TMP_DIR, TRAVIS, FONT
from test_helper import TMP_DIR, FONT



Expand All @@ -23,20 +23,14 @@ def test_download_media(capsys):
download_media.download()

def test_PR_306():
if TRAVIS:
return

#put this back in once we get ImageMagick working on travis-ci
assert TextClip.list('font') != []
assert TextClip.list('color') != []

with pytest.raises(Exception, message="Expecting Exception"):
TextClip.list('blah')

def test_PR_339():
if TRAVIS:
return

# In caption mode.
TextClip(txt='foo', color='white', font=FONT, size=(640, 480),
method='caption', align='center', fontsize=25).close()
Expand Down
18 changes: 4 additions & 14 deletions tests/test_TextClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@
from moviepy.video.VideoClip import TextClip

sys.path.append("tests")
from test_helper import TMP_DIR, TRAVIS
from test_helper import TMP_DIR

def test_duration():
#TextClip returns the following error under Travis (issue with Imagemagick)
#convert.im6: not authorized `@/tmp/tmpWL7I3M.txt' @ error/property.c/InterpretImageProperties/3057.
#convert.im6: no images defined `PNG32:/tmp/tmpRZVqGQ.png' @ error/convert.c/ConvertImageCommand/3044.
if TRAVIS:
return


clip = TextClip('hello world', size=(1280,720), color='white')
clip = clip.set_duration(5) # Changed due to #598.
assert clip.duration == 5
Expand All @@ -26,17 +21,12 @@ def test_duration():

# Moved from tests.py. Maybe we can remove these?
def test_if_textclip_crashes_in_caption_mode():
if TRAVIS:
return

TextClip(txt='foo', color='white', size=(640, 480), method='caption',
align='center', fontsize=25).close()

def test_if_textclip_crashes_in_label_mode():
if TRAVIS:
return

TextClip(txt='foo', method='label').close()


if __name__ == '__main__':
pytest.main()
pytest.main()
7 changes: 1 addition & 6 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from moviepy.video.io.VideoFileClip import VideoFileClip

import download_media
from test_helper import TMP_DIR, TRAVIS, FONT
from test_helper import TMP_DIR, FONT

sys.path.append("tests")

Expand All @@ -30,11 +30,6 @@ def test_subtitles():
myvideo = concatenate_videoclips([red,green,blue])
assert myvideo.duration == 30

#travis does not like TextClip.. so return for now..
#but allow regular users to still run the test below
if TRAVIS:
return

generator = lambda txt: TextClip(txt, font=FONT,
size=(800,600), fontsize=24,
method='caption', align='South',
Expand Down
5 changes: 1 addition & 4 deletions tests/test_videotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
from moviepy.video.tools.credits import credits1

sys.path.append("tests")
from test_helper import TMP_DIR, TRAVIS
from test_helper import TMP_DIR


def test_credits():
if TRAVIS:
# Same issue with ImageMagick on Travis as in `test_TextClip.py`
return
credit_file = "# This is a comment\n" \
"# The next line says : leave 4 blank lines\n" \
".blank 2\n" \
Expand Down

0 comments on commit 554e069

Please sign in to comment.