Change test runner to display full dotted name of test
|Patch needs improvement:
FAIL: test_output (test_runner.test_discover_runner.DiscoverRunnerTest)
The reasoning is that this is more convenient for developers: a failing test could be rerun simply by copying and pasting the test name directly from the test output, as is.
Previously, in #23332, this suggestion was closed with the following reasoning:
Django uses the built-in unittest library of Python, and the test output is entirely handled by unittest. So there is nothing in Django which could be changed to modify this output.
However, I don't think this summary is accurate because unittest makes it very easy to change the test output (I would even say it facilitates this), for example by exposing various subclass hooks on its test runner and friends. Django indeed is already doing this and modifying the test output in certain cases using
DebugSQLTextTestResult. Django also customizes
unittest's test running in other ways.
The customizability of test output is also supported by the following comment by the author of
unittest, Michael Foord, in response to a request that this change be made in unittest itself:
I agree with Robert that the text output of the default runner should not be considered a part of the "api" that we make backwards compatible guarantees about. People who want to customise that should be customising the text runner/result.
I hope you can reconsider. I put together a patch with tests and will submit a PR shortly. You will see that the change is non-intrusive and uses the customizability exposed by unittest.