1👍
✅
This is documented behaviour as far as tests are concerned:
Django’s test runner automatically redirects all Django-sent email to a dummy outbox. This lets you test every aspect of sending email – from the number of messages sent to the contents of each message – without actually sending the messages.
The test runner accomplishes this by transparently replacing the normal email backend with a testing backend.
So, your custom backend is never used in your test, which is why it fails. I think the simplest way to address this is to write your test differently, to directly call the send_messages()
method on your class, e.g.:
msg = EmailMultiAlternatives(
self.subject, self.text_content, "test@sender.de", ["test@recipient.de"])
# Note, you may have to mock out some behaviour of the backend to
# ensure it doesn't actually send an email.
BCCEmailBackend().send_messages([msg])
# This should pass now
self.assertListEqual(msg.bcc, ["should_be_send@bcc.de"], "Default bcc should be set")
Source:stackexchange.com