#15595 closed Bug (fixed)
emphasize the importance of 'from django.test import TestCase'
Reported by: | Kenneth Gonsalves | Owned by: | ShawnMilo |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
On reading the dev docs on tests one starts of with importing unittest either directly or from django.utils. The docs should clearly specify at the beginning that the optimal way is to do from django.test import TestCase as this will automatically import unittest2 as well as all the goodies.
Attachments (1)
Change History (14)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
as mike has mentioned, now django ships with import of TestCase from django.test in the sample test file in an app created by startapp. So it makes a case for putting that as default in the documentation.
comment:3 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
No, it isn't a good idea to recommend django.test.TestCase unilaterally. It's a matter of picking the right tool for the job. django.test.TestCase is an extension that contains a number of extra features for testing Django views, etc. However, those extra features have a significant overhead. If you don't need a test database for testing a particular function, you shouldn't be using django.test.testCase.
That said, django.test.TestCase is introduced quite late in the testing docs -- we should probably mention it in passing during the early stages so that the existence of the class isn't lost in the noise.
comment:4 by , 14 years ago
Type: | → Bug |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|
comment:6 by , 14 years ago
Easy pickings: | set |
---|---|
Has patch: | set |
follow-up: 8 comment:7 by , 14 years ago
Should emphasize that you get an empty test database for each test case.
comment:8 by , 14 years ago
Replying to anonymous:
Should emphasize that you get an empty test database for each test case.
Do you mean that it should be made clear that the fixtures are refreshed for each test? If so, that's a good point, and non-obvious.
Shawn
comment:9 by , 14 years ago
Owner: | changed from | to
---|
comment:10 by , 13 years ago
Cc: | added |
---|
comment:13 by , 13 years ago
Cc: | removed |
---|
I've given this thought on this here: http://groups.google.com/group/django-users/msg/b8d978e840be3905