def test__attach_objects_post_save_hook_invalid_invalid_request_error_known_exception(
        self, account, request, platform_account_fixture, configure_settings
    ):
        """Ensure _attach_objects_post_save_hook() on Account model raises Error as expected."""
        account_json, account_instance = request.getfixturevalue(account)

        assert account_instance.branding_icon is not None
        assert account_instance.branding_logo is not None

        # No exception is raised
        with patch("djstripe.models.core.File") as mock_file:
            with patch.object(
                mock_file.return_value,
                "api_retrieve",
                side_effect=stripe.error.InvalidRequestError(
                    "a similar object exists in", {}
                ),
            ):
                # Invoke _attach_objects_post_save_hook()
                account_instance._attach_objects_post_save_hook(
                    cls=Account, data=account_json, api_key=settings.STRIPE_SECRET_KEY
                )
Ensure _attach_objects_post_save_hook() on Account model raises Error as expected.
tests/test_account.py