Opened 12 years ago
Closed 11 years ago
#19885 closed Cleanup/optimization (fixed)
Make all testing tools importable from django.test
Reported by: | Anssi Kääriäinen | Owned by: | Kevin Christopher Henry |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently it is nearly impossible to remember which module has which testing item. For example:
- expectedFailure, skipUnlessDBFeature, ... is from django.test
- skipIf is from django.utils.unittest
- override_setting is from django.test.utils
- parse_html from django.test.html
I can't remember where to import these. I will always do a git grep in the test directory to see the correct import location. I would like to be able to import everything from django.test. Or at least django.utils.unittest.* + override_settings.
Is there some reason for the current split?
Change History (4)
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I think the Testing Django applications document provides a good basis for deciding what's common enough to fall under django.test
. Taking that as a basis, and taking into account that much of it is already imported into __init__.py
(and that django.utils.unittest
is no longer necessary in 1.7), I propose the following changes:
- make
override_settings
available ondjango.test
. - update the documentation to consistently use the
django.test
versions (for example, right now it references bothdjango.test.Client
anddjango.test.client.Client
). - remove
Approximate
fromdjango.test
(and update the few references to it accordingly). This is undocumented and seemingly little used, so it makes more sense to leave it atdjango.test.utils
.
comment:3 by , 11 years ago
Has patch: | set |
---|
I've left a couple minor comments on the pull request regarding cleaning up the docs, otherwise the proposal looks good to me.
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
We backported unittest2 into the Django codebase as
django.utils.unittest
because it is only available in the standard library of Python 2.7+. When we drop support for Python 2.6, we will get rid ofdjango.utils.unittest
entirely. I wouldn't have any problem with importing a common utility likeskipIf
intodjango/test/__init__.py
in parallel with the other skip-related utilities imported there; that will actually reduce the amount of search and replace we have to do when we switch from usingdjango.utils.unittest
to stdlibunittest
.Similarly I'd be fine importing
override_settings
(and anything else fromdjango.test.utils
that is commonly used) intodjango/test/__init__.py
.I don't feel quite so good about doing that with
parse_html
; HTML-parsing is a separate niche that many tests don't need, it makes sense to me to keep that segregated indjango.test.html
.