Video editing with Python
Test editor preview methods (#1583)
Álvaro Mondéjar50018de54669
diff --git a/.github/workflows/test_suite.yml b/.github/workflows/test_suite.ymlindex 25a61c3b..f1ed1ce2 100644--- a/.github/workflows/test_suite.yml+++ b/.github/workflows/test_suite.yml@@ -135,12 +135,25 @@ jobs:which pythonpython -m site --user-site- - name: Install Dependencies+ - name: Install common requirements+ run: |+ python -m pip install --upgrade wheel setuptools++ - name: Install test requirements+ if: ${{ matrix.python-version == '3.7' }}+ run: |+ python -m pip install ".[test, doc]"++ - name: Install test and optional requirements+ if: ${{ matrix.python-version != '3.7' }}run: |- python -m pip install --upgrade wheel- python -m pip install --upgrade setuptoolspython -m pip install ".[test, optional, doc]"- cat /etc/ImageMagick-6/policy.xml | sed 's/none/read,write/g' | sudo tee /etc/ImageMagick-6/policy.xml++ - name: Configure ImageMagick policy+ run: |+ cat /etc/ImageMagick-6/policy.xml \+ | sed 's/none/read,write/g' \+ | sudo tee /etc/ImageMagick-6/policy.xml- name: PyTestrun: |diff --git a/tests/test_editor.py b/tests/test_editor.pynew file mode 100644index 00000000..d5899a47--- /dev/null+++ b/tests/test_editor.py@@ -0,0 +1,50 @@+"""Moviepy editor tests."""++import importlib+import io+from contextlib import redirect_stdout++import pytest++from moviepy.audio.AudioClip import AudioClip+from moviepy.video.VideoClip import VideoClip+++def test_preview_methods():+ stdout = io.StringIO()+ with redirect_stdout(stdout):+ try:+ preview_module = importlib.import_module("moviepy.video.io.preview")+ assert preview_module.preview.__hash__() != VideoClip.preview.__hash__()+ except ImportError:+ editor_module = importlib.import_module("moviepy.editor")+ with pytest.raises(ImportError) as exc:+ VideoClip.preview(True)+ assert str(exc.value) == "clip.preview requires Pygame installed"++ with pytest.raises(ImportError) as exc:+ VideoClip.show(True)+ assert str(exc.value) == "clip.show requires Pygame installed"++ with pytest.raises(ImportError) as exc:+ AudioClip.preview(True)+ assert str(exc.value) == "clip.preview requires Pygame installed"+ else:+ editor_module = importlib.import_module("moviepy.editor")+ assert (+ editor_module.VideoClip.preview.__hash__()+ == preview_module.preview.__hash__()+ )++ try:+ importlib.import_module("matplotlib")+ except ImportError:+ editor_module = importlib.import_module("moviepy.editor")+ with pytest.raises(ImportError) as exc:+ editor_module.sliders()++ assert str(exc.value) == "sliders requires matplotlib installed"+++if __name__ == "__main__":+ pytest.main()