'Internal DRY helper.'

def check_validation_result(self, uploaded_file, expected_failure_message):

    if (expected_failure_message is not None):
        with self.assertRaises(ImageValidationError) as ctx:
            validate_uploaded_image(uploaded_file)
        self.assertEqual(ctx.exception.message, expected_failure_message)
    else:
        validate_uploaded_image(uploaded_file)
        self.assertEqual(uploaded_file.tell(), 0)
