Video editing with Python
Fix textclip filename parameter in wrong format (#1788)
Mohamed Abdultawab97870c976d24
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.pyindex ac56893c..07b04870 100644--- a/moviepy/video/VideoClip.py+++ b/moviepy/video/VideoClip.py@@ -1256,7 +1256,7 @@ class TextClip(ImageClip):text = "@" + temptxtelse:# use a file instead of a text.- text = "@%" + filename+ text = "@" + filenameif size is not None:size = (diff --git a/tests/test_TextClip.py b/tests/test_TextClip.pyindex c6703755..e30aca08 100644--- a/tests/test_TextClip.py+++ b/tests/test_TextClip.py@@ -1,5 +1,9 @@"""TextClip tests."""+import os++import numpy as np+import pytestfrom moviepy.video.fx.blink import blink@@ -35,21 +39,42 @@ def test_duration(util):assert clip2.duration == 5-# Moved from tests.py. Maybe we can remove these?-def test_if_textclip_crashes_in_caption_mode(util):- TextClip(- text="foo",- color="white",- size=(640, 480),- method="caption",- align="center",- font_size=25,- font=util.FONT,- ).close()---def test_if_textclip_crashes_in_label_mode(util):- TextClip(text="foo", method="label", font=util.FONT).close()+def test_text_filename_arguments_consistence(util):+ """Passing ``text`` or ``filename`` we obtain the same result."""+ clip_from_text = (+ TextClip(+ text="Hello",+ size=(20, 20),+ color="#000",+ bg_color="#FFF",+ method="caption",+ font=util.FONT,+ )+ .with_fps(1)+ .with_duration(1)+ )++ with open(os.path.join(util.TMP_DIR, "text-for-clip.txt"), "w") as f:+ f.write("Hello")++ clip_from_file = (+ TextClip(+ text="Hello",+ size=(20, 20),+ color="#000",+ bg_color="#FFF",+ method="caption",+ font=util.FONT,+ )+ .with_fps(1)+ .with_duration(1)+ )++ frames_from_text = list(clip_from_text.iter_frames())+ frames_from_file = list(clip_from_file.iter_frames())+ assert len(frames_from_text) == 1+ assert len(frames_from_file) == 1+ assert np.equal(frames_from_text[0], frames_from_file[0]).all()if __name__ == "__main__":