Skip to content

Video editing with Python

Added code to raise exception with string - now reformatted for approval (#1952)

stef405b5bb086439cf
diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py
index caa26828..bda75101 100644
--- a/moviepy/video/VideoClip.py
+++ b/moviepy/video/VideoClip.py
@@ -1190,6 +1190,10 @@ class ColorClip(ImageClip):
color = (0, 0, 0)
elif not hasattr(color, "__getitem__"):
raise Exception("Color has to contain RGB of the clip")
+ elif isinstance(color, str):
+ raise Exception(
+ "Color cannot be string. Color has to contain RGB of the clip"
+ )
shape = (h, w, len(color))
super().__init__(
diff --git a/tests/test_VideoClip.py b/tests/test_VideoClip.py
index 151049ba..63563053 100644
--- a/tests/test_VideoClip.py
+++ b/tests/test_VideoClip.py
@@ -264,7 +264,10 @@ def test_oncolor(util):
clip = ColorClip(size=(100, 60), color=(255, 0, 0), is_mask=True)
with pytest.raises(Exception):
- clip = ColorClip(size=(100, 60), color=0.4, is_mask=False)
+ clip = ColorClip(size=(100, 60), color=0.4, ismask=False)
+
+ with pytest.raises(Exception):
+ clip = ColorClip(size=(100, 60), color="black")
def test_setaudio(util):