Opened 13 years ago
Closed 12 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 , 13 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 12 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_settingsavailable ondjango.test. - update the documentation to consistently use the
django.testversions (for example, right now it references bothdjango.test.Clientanddjango.test.client.Client). - remove
Approximatefromdjango.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 , 12 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 , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
We backported unittest2 into the Django codebase as
django.utils.unittestbecause 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.unittestentirely. I wouldn't have any problem with importing a common utility likeskipIfintodjango/test/__init__.pyin 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.unittestto stdlibunittest.Similarly I'd be fine importing
override_settings(and anything else fromdjango.test.utilsthat 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.