Opened 8 years ago

Closed 8 years ago

Last modified 7 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


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 8 years ago.
the patch

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by Ned Batchelder

Attachment: custom-test-client.diff added

the patch

comment:1 Changed 8 years ago by Ned Batchelder

Owner: changed from nobody to Ned Batchelder
Status: newassigned

comment:2 Changed 8 years ago by Ned Batchelder

Cc: Ned Batchelder added

comment:3 Changed 8 years ago by Russell Keith-Magee

milestone: 1.3
Triage Stage: UnreviewedReady for checkin

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

comment:4 Changed 8 years ago by Russell Keith-Magee

Resolution: fixed
Status: assignedclosed

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

comment:5 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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