Opened 4 months ago

Closed 4 months ago

#35528 closed New feature (fixed)

Add EmailMultiAlternatives.body_contains() to aid email test assertions

Reported by: Ronny Vedrilla Owned by: Ronny Vedrilla
Component: Core (Mail) Version: dev
Severity: Normal Keywords: email
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, it's very hard and tedious to assert the content of an email object. Therefore, we want to add a method "body_contains()" to "EmailMultiAlternatives" to check a search string in all available text-based alternatives (content parts, like HTML).

This method can then be easily asserted in any given unit-test.

There's a forum discussion going on about this topic: https://forum.djangoproject.com/t/improve-email-unit-testing/32044/1

I've already created a PR for a suggetion: https://github.com/django/django/pull/18278/files

Change History (6)

comment:1 by Sarah Boyce, 4 months ago

Has patch: set
Summary: Added "body_contains" method to "EmailMultiAlternatives"Add EmailMultiAlternatives.body_contains() to aid email test assertions
Triage Stage: UnreviewedAccepted

comment:2 by Sarah Boyce, 4 months ago

Owner: changed from nobody to Ronny Vedrilla
Status: newassigned

comment:3 by Sarah Boyce, 4 months ago

Patch needs improvement: set

comment:4 by Sarah Boyce, 4 months ago

Patch needs improvement: unset

comment:5 by Sarah Boyce, 4 months ago

Triage Stage: AcceptedReady for checkin

comment:6 by Sarah Boyce <42296566+sarahboyce@…>, 4 months ago

Resolution: fixed
Status: assignedclosed

In 5fef6d2:

Fixed #35528 -- Added EmailMultiAlternatives.body_contains() helper method.

Note: See TracTickets for help on using tickets.
Back to Top