Video editing with Python
Remove TravisCI related code from tests; fix matplotlib test (#1417)
Álvaro Mondéjar20633adf256d
diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.ymlindex a2ec5cc4..c434745e 100644--- a/.github/workflows/test_suite.yml+++ b/.github/workflows/test_suite.yml@@ -56,7 +56,7 @@ jobs:brew install pkg-configpython -m pip install --upgrade wheelpython -m pip install --upgrade setuptools- python -m pip install ".[test]"+ python -m pip install ".[test, optional]"- name: Test with pytestrun: |diff --git a/appveyor.yml b/appveyor.ymlindex 41c77834..daa77a8b 100644--- a/appveyor.yml+++ b/appveyor.yml@@ -55,7 +55,7 @@ install:build_script:# Install all dependencies, including dev dependencies- - pip install .[test]+ - pip install ".[test, optional]"test_script:- pytestdiff --git a/tests/test_examples.py b/tests/test_examples.pyindex e9948cd2..76550202 100644--- a/tests/test_examples.py+++ b/tests/test_examples.py@@ -7,7 +7,7 @@ import pytestfrom moviepy.video.io.bindings import mplfig_to_npimagefrom moviepy.video.VideoClip import VideoClip-from tests.test_helper import PYTHON_VERSION, TMP_DIR, TRAVIS+from tests.test_helper import TMP_DIRtry:import matplotlib@@ -17,7 +17,6 @@ except ImportError:@pytest.mark.skipif(True, reason="testing on github actions")@pytest.mark.skipif(not matplotlib, reason="no mpl")[email protected](PYTHON_VERSION == "3.5", reason="travis py35")def test_matplotlib():# for now, python 3.5 installs a version of matplotlib that complains# about $DISPLAY variable, so lets just ignore for now.diff --git a/tests/test_helper.py b/tests/test_helper.pyindex d627e16a..757f5af6 100644--- a/tests/test_helper.py+++ b/tests/test_helper.py@@ -4,7 +4,6 @@ import osimport sysimport tempfile-TRAVIS = os.getenv("TRAVIS_PYTHON_VERSION") is not NonePYTHON_VERSION = "%s.%s" % (sys.version_info.major, sys.version_info.minor)TMP_DIR = tempfile.gettempdir() # because tempfile.tempdir is sometimes Nonediff --git a/tests/test_issues.py b/tests/test_issues.pyindex 9bc086d9..369815ac 100644--- a/tests/test_issues.py+++ b/tests/test_issues.py@@ -8,7 +8,7 @@ from moviepy.utils import close_all_clipsfrom moviepy.video.fx.blink import blinkfrom moviepy.video.fx.resize import resize-from tests.test_helper import PYTHON_VERSION, TMP_DIR, TRAVIS+from tests.test_helper import TMP_DIRdef test_issue_145():@@ -257,43 +257,49 @@ def test_issue_359():video.write_gif(filename=os.path.join(TMP_DIR, "issue_359.gif"), tempfiles=True)-# TODO: Debug matplotlib failures following successful travis builds.-# def test_issue_368():-# # Travis/3.5 fails.-# if PYTHON_VERSION == '3.5' and TRAVIS:-# return-#-# import numpy as np-# import matplotlib.pyplot as plt-# from sklearn import svm-# from sklearn.datasets import make_moons-# from moviepy.video.io.bindings import mplfig_to_npimage-#-# X, Y = make_moons(50, noise=0.1, random_state=2) # semi-random data-#-# fig, ax = plt.subplots(1, figsize=(4, 4), facecolor=(1,1,1))-# fig.subplots_adjust(left=0, right=1, bottom=0)-# xx, yy = np.meshgrid(np.linspace(-2,3,500), np.linspace(-1,2,500))-#-# def make_frame(t):-# ax.clear()-# ax.axis('off')-# ax.set_title("SVC classification", font_size=16)-#-# classifier = svm.SVC(gamma=2, C=1)-# # the varying weights make the points appear one after the other-# weights = np.minimum(1, np.maximum(0, t**2+10-np.arange(50)))-# classifier.fit(X, Y, sample_weight=weights)-# Z = classifier.decision_function(np.c_[xx.ravel(), yy.ravel()])-# Z = Z.reshape(xx.shape)-# ax.contourf(xx, yy, Z, cmap=plt.cm.bone, alpha=0.8,-# vmin=-2.5, vmax=2.5, levels=np.linspace(-2,2,20))-# ax.scatter(X[:,0], X[:,1], c=Y, s=50*weights, cmap=plt.cm.bone)-#-# return mplfig_to_npimage(fig)-#-# animation = VideoClip(make_frame, duration=2)-# animation.write_gif(os.path.join(TMP_DIR, "svm.gif"), fps=20)+def test_issue_368():+ import numpy as np+ import matplotlib+ import matplotlib.pyplot as plt+ from sklearn import svm+ from sklearn.datasets import make_moons+ from moviepy.video.io.bindings import mplfig_to_npimage++ plt.switch_backend("agg")++ X, Y = make_moons(50, noise=0.1, random_state=2) # semi-random data++ fig, ax = plt.subplots(1, figsize=(4, 4), facecolor=(1, 1, 1))+ fig.subplots_adjust(left=0, right=1, bottom=0)+ xx, yy = np.meshgrid(np.linspace(-2, 3, 500), np.linspace(-1, 2, 500))++ def make_frame(t):+ ax.clear()+ ax.axis("off")+ ax.set_title("SVC classification", fontsize=16)++ classifier = svm.SVC(gamma=2, C=1)+ # the varying weights make the points appear one after the other+ weights = np.minimum(1, np.maximum(0, t ** 2 + 10 - np.arange(50)))+ classifier.fit(X, Y, sample_weight=weights)+ Z = classifier.decision_function(np.c_[xx.ravel(), yy.ravel()])+ Z = Z.reshape(xx.shape)+ ax.contourf(+ xx,+ yy,+ Z,+ cmap=plt.cm.bone,+ alpha=0.8,+ vmin=-2.5,+ vmax=2.5,+ levels=np.linspace(-2, 2, 20),+ )+ ax.scatter(X[:, 0], X[:, 1], c=Y, s=50 * weights, cmap=plt.cm.bone)++ return mplfig_to_npimage(fig)++ animation = VideoClip(make_frame, duration=2)+ animation.write_gif(os.path.join(TMP_DIR, "svm.gif"), fps=20)def test_issue_407():