def check_dimensions(self, instance, width, height,<EOL>field_name='<STR_LIT>'):
field = getattr(instance, field_name)<EOL>if width is None and height is None:<EOL><INDENT>with self.assertRaises(ValueError):<EOL><INDENT>getattr(field, '<STR_LIT:width>')<EOL><DEDENT>with self.assertRaises(ValueError):<EOL><INDENT>getattr(field, '<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.assertEqual(field.width, width)<EOL>self.assertEqual(field.height, height)<EOL><DEDENT>width_field_name = field_name + '<STR_LIT>'<EOL>if hasattr(instance, width_field_name):<EOL><INDENT>self.assertEqual(getattr(instance, width_field_name), width)<EOL><DEDENT>height_field_name = field_name + '<STR_LIT>'<EOL>if hasattr(instance, height_field_name):<EOL><INDENT>self.assertEqual(getattr(instance, height_field_name), height)<EOL><DEDENT>
Asserts that the given width and height values match both the
field's height and width attributes and the height and width fields
(if defined) the image field is caching to.

Note, this method will check for dimension fields named by adding
"_width" or "_height" to the name of the ImageField.  So, the
models used in these tests must have their fields named
accordingly.

By default, we check the field named "mugshot", but this can be
specified by passing the field_name parameter.