Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#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)

15595_TestCase_docs.diff (1.1 KB ) - added by ShawnMilo 13 years ago.
Changes at Russell's suggestion.

Download all attachments as: .zip

Change History (14)

comment:2 by Kenneth Gonsalves, 13 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 Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

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 Luke Plant, 13 years ago

Type: Bug

comment:5 by Luke Plant, 13 years ago

Severity: Normal

by ShawnMilo, 13 years ago

Attachment: 15595_TestCase_docs.diff added

Changes at Russell's suggestion.

comment:6 by ShawnMilo, 13 years ago

Easy pickings: set
Has patch: set

comment:7 by anonymous, 13 years ago

Should emphasize that you get an empty test database for each test case.

in reply to:  7 comment:8 by ShawnMilo, 13 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 ShawnMilo, 13 years ago

Owner: changed from nobody to ShawnMilo

comment:10 by Dougal Matthews, 13 years ago

Cc: dougal85@… added

comment:11 by Chris Beaven, 13 years ago

Resolution: fixed
Status: newclosed

In [16214]:

Fixes #15595 -- emphasize the benefits of django.test.TestCase. Thanks for the patch Shawn Milochik

comment:12 by Chris Beaven, 13 years ago

In [16215]:

[1.3.X] Fixes #15595 -- emphasize the benefits of django.test.TestCase. Thanks for the patch Shawn Milochik

Backport of r16214 from trunk.

comment:13 by Dougal Matthews, 13 years ago

Cc: dougal85@… removed
Note: See TracTickets for help on using tickets.
Back to Top