Opened 3 weeks ago

Closed 4 days ago

Last modified 4 days ago

#37128 closed Cleanup/optimization (fixed)

Include setUpTestData as a way to speed up tests

Reported by: Tim Schilling Owned by: Tim Schilling
Component: Documentation Version: dev
Severity: Normal Keywords: testing
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

In Adam Johnson's book "Speed up your Django Tests", there's a section on using setUpTestData to speed up tests. Since we have a section on speeding up tests already, I think we should add this tip to it. We also mention in docs/topics/testing/tools.txt, that setUpTestData is faster than using setUp.

Change History (8)

comment:1 by Jacob Walls, 3 weeks ago

Triage Stage: UnreviewedAccepted

Sounds good. I also think the AnimalTestCase example at the top of that page should be updated. It's a little debatable, since part of the point of that section is to demonstrate that TestCase is a lightweight subclass of unittest.TestCase, and we'd be immediately showing a custom method, but we should be able to clarify that with some appropriate wording.

comment:2 by Tim Schilling, 3 weeks ago

Owner: set to Tim Schilling
Status: newassigned

comment:3 by Tim Schilling, 3 weeks ago

Has patch: set

comment:4 by Jacob Walls, 2 weeks ago

Patch needs improvement: set

comment:5 by Tim Schilling, 2 weeks ago

Patch needs improvement: unset

comment:6 by Jacob Walls, 9 days ago

Triage Stage: AcceptedReady for checkin

comment:7 by Jacob Walls <jacobtylerwalls@…>, 4 days ago

Resolution: fixed
Status: assignedclosed

In d80ef32:

Fixed #37128 -- Doc'd setUpTestData as test speed up.

Revises the AnimalTestCase to better show test data isolation
and avoid the opportunity to use setUpTestData.

comment:8 by Jacob Walls <jacobtylerwalls@…>, 4 days ago

In 8cfba50:

[6.1.x] Fixed #37128 -- Doc'd setUpTestData as test speed up.

Revises the AnimalTestCase to better show test data isolation
and avoid the opportunity to use setUpTestData.

Backport of d80ef32eb9e669986ed7838296f6373af56c68f0 from main.

Note: See TracTickets for help on using tickets.
Back to Top