Opened 15 years ago
Closed 13 years ago
#15896 closed Bug (wontfix)
unittest docs say import django.utils, should be djanto.test
| Reported by: | Roy Smith | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
At http://docs.djangoproject.com/en/1.3/topics/testing/#writing-unit-tests, it says:
from django.utils import unittest
It should import from django.test, no? It's wrong in the release notes too. The sample tests.py file gets it right.
Change History (5)
comment:1 by , 15 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 15 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
Hmm, OK, I read this a little more carefully and see what had me going. The docs say:
from django.utils import unittest
but the sample tests.py file says:
from django.test import TestCase
this is a little confusing. It would be more obvious if the sample and the docs did it the same way.
comment:3 by , 15 years ago
| Resolution: | → invalid |
|---|---|
| Status: | reopened → closed |
It's a different thing. django.utils.unittest is a copy of the unittest2 package for Python < 2.7. django.test holds Django's special testsuite helpers.
In most cases you don't need to import anything from django.utils.unittest. It's just some kind of warning to prevent you from using import unittest.
comment:4 by , 13 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → new |
| UI/UX: | unset |
A problem persists. The docs start by samples with from django.utils import unittest, but the example tests.py created by python manage.py startapp says from django.test import TestCase. That might confuse people starting to write tests. The docs do mention something about the difference, but only after a few pagefuls.
comment:5 by , 13 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
They really are two different things, used for two different purposes. I'm going to close this again; if you feel strongly, please take it to django-dev for discussion.
Ever tried to do so?