Fixed `ValueError` not raised (#5095)

Raised `ValueError` in `wagtail/images/utils.py` that was called but not raised

I work for Semmle and I noticed these issues using our LGTM code analyzer
https://lgtm.com/projects/g/wagtail/wagtail/alerts/?mode=tree&severity=error&ruleFocus=1505923886371
pull/5109/head
damianos 2019-02-20 15:55:15 +00:00 zatwierdzone przez Matt Westcott
rodzic 234ee703ed
commit 20f47ff50e
3 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -347,6 +347,7 @@ Contributors
* Vladimir Knobel
* Matt Collins
* Thomas Elliott
* damianosSemmle
Translators
===========

Wyświetl plik

@ -619,3 +619,11 @@ class TestBackgroundColorFilter(TestCase):
file=get_test_image_file(),
)
self.assertRaises(ValueError, fil.run, image, BytesIO())
def test_invalid_length(self):
fil = Filter(spec='width-400|bgcolor-1234')
image = Image.objects.create(
title="Test image",
file=get_test_image_file(),
)
self.assertRaises(ValueError, fil.run, image, BytesIO())

Wyświetl plik

@ -57,6 +57,6 @@ def parse_color_string(color_string):
g = int(color_string[2:4], 16)
b = int(color_string[4:6], 16)
else:
ValueError('Color string must be either 3 or 6 hexadecimal digits long')
raise ValueError('Color string must be either 3 or 6 hexadecimal digits long')
return r, g, b