Opened 11 years ago
Closed 11 years ago
#21641 closed New feature (wontfix)
Django distributes BaseEmailBackendTests
Reported by: | Benoît Bryon | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.6 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
As of version 1.6:
- Django documentation tells you can create custom email backends: https://docs.djangoproject.com/en/1.6/topics/email/#defining-a-custom-email-backend
- Django has a BaseEmailBackendTests class in repository's "tests" folder: https://github.com/django/django/blob/09f865276554f35060ff939722ec4cefd578edf6/tests/mail/tests.py#L333
Unfortunately, the BaseEmailBackendTests class is not included in Django package, i.e. Django users cannot import it after Django has been installed.
As a Django user, in order to test a custom email backend, I want to reuse BaseEmailBackendTests provided by Django.
I expect something like "from django.test.mail import BaseEmailBackendTests".
I suppose documentation should be updated too, with some section about "How to test custom email backend".
I suppose tests of Django backends such as LocmemBackendTests can stay in "tests" folder, and "tests/mail/tests.py" imports BaseEmailBackendTests from django package.
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
we are no longer free to modify or extend them as we wish, for fear of breaking backwards compatibility in user's test suites
Perhaps the BaseEmailBackendTests cannot be moved as is from "tests/" to "django/test/". Perhaps it requires to be splitted and/or refactored.
I believed every email backend has to conform to an API. Else, email backends are not interchangeable.
If email backends are supposed to be interchangeable, I expect some "django.test.mail.BaseEmailBackendTests" to check at least the API. Perhaps more when it is relevant.
If Django's email backend API changes, then I expect the tests of custom email backends to fail. This is a valuable feature IMHO.
I do not expect such a base test case to check implementation internals.
I must admit I did not dive into BaseEmailBackendTests implementation, so that I cannot tell if it is really specific to Django.
But a colleague of mine has just created a custom email backend and copied/pasted/hacked the BaseEmailBackendTests class... I believe it would have been easier to code, and it would be easier to maintain if Django provided the base test case.
comment:3 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
While I appreciate that this may be useful for you, I agree with Marc that this is likely to cause us more maintenance headaches than it would likely be worth (defining a stable API, documenting it, committing to backwards compatability, etc.). The set of people needing this feature is likely to be small and the workaround of pulling the class from Django's is relatively simple. If you are really enthusiastic about this and want to work on a patch, we could consider it, but I don't want you to be disappointed if it isn't accepted.
Personally, I do not agree with the premise of this ticket. If we move these tests as described then we are no longer free to modify or extend them as we wish, for fear of breaking backwards compatibility in user's test suites. I acknowledge that writing custom email backends is a relatively unusual thing to do and we are unlikely to get a large number of problems, but the point stands more generally.
Finally, it is perfectly reasonable to assume that any given custom email backend might not comply perfectly with all of the tests in
BaseEmailBackendTests
, thus making the concept useless anyway.I'm not going to close this as I'd like a second opinion.