[Django] #26981: Support passing custom kwargs to DiscoverRunner's test runner

35 views
Skip to first unread message

Django

unread,
Aug 1, 2016, 5:36:21 PM8/1/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+--------------------
Reporter: cjerdonek | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
Currently, there doesn't seem to be a nice way to have Django pass custom
kwargs to the underlying unittest test runner when running tests.

This is because Django hard-codes the kwargs it passes (see
[https://github.com/django/django/blob/013ee21cf8e1a4b05589c161039f244e356272ba/django/test/runner.py#L505
here] for a direct link to the code):

{{{#!python
def run_suite(self, suite, **kwargs):
resultclass = self.get_resultclass()
return self.test_runner(
verbosity=self.verbosity,
failfast=self.failfast,
resultclass=resultclass,
).run(suite)
}}}

Django's default test runner is `unittest.TextTestRunner`, and here are
all of the kwargs that the runner currently supports (from the function
signature in Python 3.5.2):

{{{#!python
class TextTestRunner(object):

def __init__(self, stream=None, descriptions=True, verbosity=1,
failfast=False, buffer=False, resultclass=None,
warnings=None,
*, tb_locals=False):
}}}

One approach to this ticket might involve having `run_suite()` pass its
kwargs along to the test runner function (instead of "swallowing" them),
and making whatever other code changes are needed to support this (e.g.
modifying `run_tests()` to pass kwargs along to `run_suite()`). More
focused approaches are also possible.

--
Ticket URL: <https://code.djangoproject.com/ticket/26981>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 1, 2016, 9:42:25 PM8/1/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+--------------------------------------

Reporter: cjerdonek | Owner: nobody
Type: Uncategorized | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by cjerdonek):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Also, to ground this in reality, the use case I am / was interested in is
passing a custom `stream` to the underlying `TextTestRunner`.

--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:1>

Django

unread,
Aug 2, 2016, 4:59:33 AM8/2/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+--------------------------------------
Reporter: cjerdonek | Owner: cjerdonek
Type: Uncategorized | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by cjerdonek):

* owner: nobody => cjerdonek
* status: new => assigned
* version: 1.9 => master


--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:2>

Django

unread,
Aug 2, 2016, 5:16:07 AM8/2/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+--------------------------------------
Reporter: cjerdonek | Owner: cjerdonek
Type: Uncategorized | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by cjerdonek):

I started working on this in branch
[https://github.com/cjerdonek/django/tree/ticket_26981 ticket_26981] of my
GitHub repo.

--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:3>

Django

unread,
Aug 2, 2016, 3:31:19 PM8/2/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: cjerdonek
Type: New feature | Status: assigned

Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+-------------------------------------
Changes (by timgraham):

* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:4>

Django

unread,
Aug 2, 2016, 6:58:29 PM8/2/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: cjerdonek
Type: New feature | Status: assigned
Component: Testing framework | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+-------------------------------------
Changes (by cjerdonek):

* has_patch: 0 => 1


Comment:

I posted a pull request for this in my GitHub repo
[https://github.com/django/django/pull/7009 here].

--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:5>

Django

unread,
Aug 4, 2016, 2:46:16 PM8/4/16
to django-...@googlegroups.com
#26981: Support passing custom kwargs to DiscoverRunner's test runner
-----------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: cjerdonek
Type: New feature | Status: closed

Component: Testing framework | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"ebed9ee8d5e4268d9393261633b2c23cffd426fc" ebed9ee8]:
{{{
#!CommitTicketReference repository=""
revision="ebed9ee8d5e4268d9393261633b2c23cffd426fc"
Fixed #26981 -- Added DiscoverRunner.get_test_runner_kwargs().
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26981#comment:6>

Reply all
Reply to author
Forward
0 new messages