Skip to content

Commit

Permalink
add test_helper.py to set variables used for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bearney74 committed Mar 14, 2017
1 parent e8ab2de commit 7b5c0d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
6 changes: 6 additions & 0 deletions tests/test_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

TRAVIS=os.getenv("TRAVIS_PYTHON_VERSION") is not None

TMP_DIR="/tmp"

23 changes: 10 additions & 13 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import sys
sys.path.append("tests")
import download_media
from test_helper import TRAVIS, TMP_DIR


def test_download_media(capsys):
with capsys.disabled():
Expand All @@ -24,23 +26,19 @@ def test_subtitles():
myvideo = concatenate_videoclips([red,green,blue])
assert myvideo.duration == 30

if os.getenv("TRAVIS_PYTHON_VERSION") is None:
generator = lambda txt: TextClip(txt, font='Georgia-Regular',
#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='Georgia-Regular',
size=(800,600), fontsize=24,
method='caption', align='South',
color='white')
else:
#travis-ci doesn't like TextClip
def generator(txt):
class Temp:
def __init__(self):
self.mask=None

return Temp()

subtitles = SubtitlesClip("media/subtitles1.srt", generator)
final = CompositeVideoClip([myvideo, subtitles])
final.to_videofile("/tmp/subtitles1.mp4", fps=30)
final.to_videofile(os.path.join(TMP_DIR, "subtitles1.mp4"), fps=30)

data = [([0.0, 4.0], 'Red!'), ([5.0, 9.0], 'More Red!'),
([10.0, 14.0], 'Green!'), ([15.0, 19.0], 'More Green!'),
Expand All @@ -53,5 +51,4 @@ def __init__(self):


if __name__ == '__main__':
test_subtitles()
#pytest.main()
pytest.main()

0 comments on commit 7b5c0d9

Please sign in to comment.