Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#14378 closed (fixed)

Enable customization of the class for self.client in tests

Reported by: Ned Batchelder Owned by: Ned Batchelder
Component: Testing framework Version: 1.2
Severity: Keywords:
Cc: Ned Batchelder Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The attached patch removes the hard connection between test.TestCase and test.client.Client, instead making the class of client a class attribute on TestCase. This allows sub-classes of TestCase to specify a custom sub-class of Client to use in their tests.

While it's possible to create your own self.client in a setUp method, this keeps the code simpler. For example, I could set this class attribute once on my own base TestCase class, and all my test cases would use it without having to invoke setUp on the base class, just as the built-in TestCase class does.

Attachments (1)

custom-test-client.diff (2.4 KB ) - added by Ned Batchelder 14 years ago.
the patch

Download all attachments as: .zip

Change History (6)

by Ned Batchelder, 14 years ago

Attachment: custom-test-client.diff added

the patch

comment:1 by Ned Batchelder, 14 years ago

Owner: changed from nobody to Ned Batchelder
Status: newassigned

comment:2 by Ned Batchelder, 14 years ago

Cc: Ned Batchelder added

comment:3 by Russell Keith-Magee, 14 years ago

milestone: 1.3
Triage Stage: UnreviewedReady for checkin

Looks good to me. Thanks for the idea and patch, Ned.

comment:4 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [14058]) Fixed #14378 -- Made the test client class customizable. Thanks to Ned Batchelder for the patch.

comment:5 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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