Skip to content

Instantly share code, notes, and snippets.

@aaronlelevier
Created January 27, 2018 02:04
Show Gist options
  • Select an option

  • Save aaronlelevier/eb0155c3aadb4314c3c75544db13e9ee to your computer and use it in GitHub Desktop.

Select an option

Save aaronlelevier/eb0155c3aadb4314c3c75544db13e9ee to your computer and use it in GitHub Desktop.
Has friendly test fail header formatting so the test header matches syntax for running a single test
from nose.result import TextTestResult as NoseTextTestResult
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment