The reason that I want to do this is that I frequently copy and paste the header text in order to re-run a single failed test. But, the standard output doesn't let you easily copy and paste it into the terminal, so I'd like to be able to update the output to do format it within the "(...)" so it is the library's accepted format for running a single test.
In order to do this override, I would like to do use the following code, but I am not sure where to inject it.
class TextTestResult(NoseTextTestResult):
def getDescription(self, test):
"""
Overrides the default test header, so the failed test name
can be copied as is and syntax works to be able to run the
single test "as copied" from this output.
Example:
'myapp.tests.test_models:MyModelTests.test_foo'
Returns:
str (always)
"""
return '({module}:{test_class}.{test_method})'.format(
module=test.test.__class__.__module__,
test_class=test.test.__class__.__name__,
test_method=test.test._testMethodName)
Can you advise if this is possible? Or how to inject / override to get this behavior?
I'd like to be able to change the default header output on a failed test. I'd like to change it from:
To:
The reason that I want to do this is that I frequently copy and paste the header text in order to re-run a single failed test. But, the standard output doesn't let you easily copy and paste it into the terminal, so I'd like to be able to update the output to do format it within the "(...)" so it is the library's accepted format for running a single test.
In order to do this override, I would like to do use the following code, but I am not sure where to inject it.
Can you advise if this is possible? Or how to inject / override to get this behavior?
Thanks