Five seconds may seem small but it is really significant when you're
rapidly alternating between writing code and running tests, and it's
totally unnecessary to set a `Message-ID` header on emails in
`django.core.mail.backends.locmem`. Right now my large test suite runs in
600 ms if I comment out that one pesky call that turns it into 5800 ms. So
while this isn't a bug, I think fixing it would be a really nice quality-
of-life change.
--
Ticket URL: <https://code.djangoproject.com/ticket/24380>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
We might argue that the real bug is your machine's `socket.getfqdn()`
slowness. I'm not sure it's a good idea to strip the `locmem` backend (see
#18861 about the reason this was introduced).
I think the solution would be for you to mock `socket.getfqdn()` in your
tests.
Keeping it open for getting another opinion.
--
Ticket URL: <https://code.djangoproject.com/ticket/24380#comment:1>
* status: new => closed
* resolution: => wontfix
Comment:
I agree, I think the locmem backend should handle messages as similarly as
possible to the real backend. If `socket.getfqdn()` is a problem on your
particular machine, it shouldn't be hard to mock it for your tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/24380#comment:2>
Comment (by fletom):
I also agree that your suggestion to use a mock monkey patch is a better
idea that changing the `locmem` backend just for tests. Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/24380#comment:3>
Comment (by Jonas Haag):
I've come up with a simple email backend subclass/mixin that doesn't
require monkeypatching. Check it out here:
https://gist.github.com/jonashaag/69ed72632e0780899755b592492756dd
--
Ticket URL: <https://code.djangoproject.com/ticket/24380#comment:4>