Opened 8 years ago
Closed 8 years ago
#26981 closed New feature (fixed)
Support passing custom kwargs to DiscoverRunner's test runner
Reported by: | Chris Jerdonek | Owned by: | Chris Jerdonek |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 here for a direct link to the code):
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):
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.
Change History (6)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Version: | 1.9 → master |
comment:4 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Uncategorized → New feature |
Also, to ground this in reality, the use case I am / was interested in is passing a custom
stream
to the underlyingTextTestRunner
.