Opened 13 years ago

Closed 11 years ago

#16534 closed Cleanup/optimization (fixed)

DiscoverRunner API makes re-use difficult.

Reported by: Tom Christie Owned by: Cliff Dyer
Component: Testing framework Version: dev
Severity: Normal Keywords:
Cc: andy@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Would be better if it allowed the test suite class and test runner class to be overridden.

Attachments (6)

djangotestsuiterunner.diff (1.3 KB ) - added by Tom Christie 13 years ago.
djangotestsuiterunner-2.diff (4.0 KB ) - added by Tom Christie 13 years ago.
Also allow test_runner to be overridden
djangotestsuiterunner-3.diff (3.0 KB ) - added by Cliff Dyer 11 years ago.
New patch that works with DiscoverRunner instead of DjangoTestSuiteRunner
djangotestsuiterunner-4.diff (4.7 KB ) - added by Cliff Dyer 11 years ago.
Added documentation updates suggested on IRC by timograham
djangotestsuiterunner-4.diff​ (4.7 KB ) - added by Cliff Dyer 11 years ago.
Added documentation updates suggested on IRC by timograham (edited to fix a documentation typo: DicsoverRunner)
discoverrunner-with-tests.diff (5.7 KB ) - added by Cliff Dyer 11 years ago.
One last attachment, this one with tests.

Download all attachments as: .zip

Change History (24)

by Tom Christie, 13 years ago

Attachment: djangotestsuiterunner.diff added

comment:2 by Jannis Leidel, 13 years ago

Needs documentation: set
Needs tests: set

Sounds like a reasonable idea.

comment:3 by Jannis Leidel, 13 years ago

Triage Stage: UnreviewedAccepted

comment:4 by Tom Christie, 13 years ago

Being able to override the test loader too would be even better...

by Tom Christie, 13 years ago

Also allow test_runner to be overridden

comment:5 by Andy Baker <andy@…>, 13 years ago

Cc: andy@… added
Needs documentation: unset
Needs tests: unset

Don't think this needs documentation - it's an internal interface, and don't think it needs tests as it's clean-up, not new functionality.

comment:6 by Tom Christie, 13 years ago

Hadn't noticed those were still set. Thanks.

comment:7 by Ramiro Morales, 13 years ago

Needs documentation: set

DjangotestSuiteRunner is documented, changes introduced for this ticket also need documentation.

in reply to:  7 comment:8 by Tom Christie, 13 years ago

Replying to ramiro:

DjangotestSuiteRunner is documented, changes introduced for this ticket also need documentation.

Ah, true. I'll get that sorted, then...

comment:9 by Tom Christie, 11 years ago

Don't know how this patch applies given 1.6's incoming test runner changes, if anyone's picking this up at DjangoCon, that'd need investigation first...

comment:10 by Cliff Dyer, 11 years ago

I'm taking a look at this....

comment:11 by Cliff Dyer, 11 years ago

So it doesn't apply as is. I've modified to to work with the new subclassing of DiscoverRunner. All tests still pass. I'm looking into the documentation situation, and then I'll be uploading a patch.

by Cliff Dyer, 11 years ago

New patch that works with DiscoverRunner instead of DjangoTestSuiteRunner

comment:12 by Cliff Dyer, 11 years ago

Owner: changed from Tom Christie to Cliff Dyer
Status: newassigned

Looking more closely, DjangoTestSuiteRunner is deprecated. Updating it seems like the wrong way to move forward. Instead, we should ensure that the new hotness (DiscoverRunner) contains the requested features.

It already allows overriding test_loader. Following the example in previous patches, I have updated DiscoverRunner to allow overriding the test suite and the unittest-level test runner (TextTestRunner). I have also updated the documentation of DiscoverRunner at topics/testing/advanced/ to detail these attributes.

In a small departure from earlier patches, I have taken the liberty of renaming suite_class to test_suite (for consistency with test_runner and test_loader). Because it is pending deprecation, no enhancements have been made to django.test.simple or the DjangoTestSuiteRunner.

comment:13 by Cliff Dyer, 11 years ago

Needs documentation: unset

by Cliff Dyer, 11 years ago

Added documentation updates suggested on IRC by timograham

comment:14 by Cliff Dyer, 11 years ago

Version: 1.3master

comment:15 by Cliff Dyer, 11 years ago

Summary: DjangoTestSuiteRunner API makes re-use difficult.DiscoverRunner API makes re-use difficult.

Changed the ticket title to reflect the new direction of the ticket.

by Cliff Dyer, 11 years ago

Added documentation updates suggested on IRC by timograham (edited to fix a documentation typo: DicsoverRunner)

by Cliff Dyer, 11 years ago

One last attachment, this one with tests.

comment:16 by Cliff Dyer, 11 years ago

I added tests. They're pretty brain dead, because the entire change was an attribute creation refactor, but now that the attributes are documented, we want to be notified if they go away or become the wrong thing.

comment:17 by Cliff Dyer, 11 years ago

Created a ticket to track backporting some documentation changes to 1.6.

comment:18 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 4ba373840a7b299fff4a7bcc1001e32dffceee86:

Fixed #16534 -- Improved ability to customize DiscoverRunner

Added DiscoverRunner.test_suite and .test_runner attributes.

Thanks tomchristie for the suggestion and jcd for the patch.

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