Skip to content

Commit 0a75aff

Browse files
committed
Always warn when width and height fields are missing
Closes #227
1 parent 721cd80 commit 0a75aff

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

pictures/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def _check_aspect_ratios(self):
291291
return errors
292292

293293
def _check_width_height_field(self):
294-
if None in self.aspect_ratios and not (self.width_field and self.height_field):
294+
if not (self.width_field and self.height_field):
295295
return [
296296
checks.Warning(
297297
"width_field and height_field attributes are missing",

tests/test_models.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,19 @@ def test_check_aspect_ratios(self):
825825
assert errors
826826
assert errors[0].id == "fields.E100"
827827

828-
def test_check_width_height_field(self):
829-
assert not PictureField(aspect_ratios=["3/2"])._check_width_height_field()
830-
with override_field_aspect_ratios(Profile.picture.field, [None]):
828+
@pytest.mark.parametrize(
829+
"aspect_ratios",
830+
[
831+
("3/2",),
832+
(None,),
833+
(
834+
"3/2",
835+
None,
836+
),
837+
],
838+
)
839+
def test_check_width_height_field(self, aspect_ratios):
840+
with override_field_aspect_ratios(Profile.picture.field, aspect_ratios):
831841
errors = Profile.picture.field._check_width_height_field()
832842
assert errors
833843
assert errors[0].id == "fields.E101"

0 commit comments

Comments
 (0)