diff --git a/pictures/models.py b/pictures/models.py index 4b3f326..77500d6 100644 --- a/pictures/models.py +++ b/pictures/models.py @@ -291,7 +291,7 @@ def _check_aspect_ratios(self): return errors def _check_width_height_field(self): - if None in self.aspect_ratios and not (self.width_field and self.height_field): + if not (self.width_field and self.height_field): return [ checks.Warning( "width_field and height_field attributes are missing", diff --git a/tests/test_models.py b/tests/test_models.py index 00fa40c..b6af2ea 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -825,9 +825,19 @@ def test_check_aspect_ratios(self): assert errors assert errors[0].id == "fields.E100" - def test_check_width_height_field(self): - assert not PictureField(aspect_ratios=["3/2"])._check_width_height_field() - with override_field_aspect_ratios(Profile.picture.field, [None]): + @pytest.mark.parametrize( + "aspect_ratios", + [ + ("3/2",), + (None,), + ( + "3/2", + None, + ), + ], + ) + def test_check_width_height_field(self, aspect_ratios): + with override_field_aspect_ratios(Profile.picture.field, aspect_ratios): errors = Profile.picture.field._check_width_height_field() assert errors assert errors[0].id == "fields.E101"