Skip to content

Commit 796fb5f

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

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,9 +825,11 @@ 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", (("3/2",), (None,), ("3/2", None,))
830+
)
831+
def test_check_width_height_field(self, aspect_ratios):
832+
with override_field_aspect_ratios(Profile.picture.field, aspect_ratios):
831833
errors = Profile.picture.field._check_width_height_field()
832834
assert errors
833835
assert errors[0].id == "fields.E101"

0 commit comments

Comments
 (0)