Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: option to print __name__ of test instead of __doc__ #14

Open
jpellerin opened this issue Dec 14, 2011 · 3 comments
Open
Assignees

Comments

@jpellerin
Copy link
Member

Currently if a test function does not have a docstring it's name is printed
at verbosity=2. However, if the function does have a docstring then that
is printed instead of the name and there is no way to change this behavior.
I propose an option to choose between name and doc. (--func-name
perhaps).

I think this code from case.py governs the "name" of a test:
{{{
class TestBase(unittest.TestCase):

def shortDescription(self):
if hasattr(self.test, 'description'):
return self.test.description
func, arg = self._descriptors()
doc = getattr(func, 'doc', None)
if not doc:
doc = str(self)
return doc.strip().split("\n")[0].strip()
}}}

Google Code Info:
Issue #: 214
Author: [email protected]
Created On: 2008-10-31T15:09:41.000Z
Closed On:

@jpellerin
Copy link
Member Author

Yes please! nosetests prints either the name of the test function or the first
sentence of the docstring. This means that, when running nosetests with -v, the
output looks very inconsistent if some test cases has docstrings.

Google Code Info:
Author: [email protected]
Created On: 2009-12-04T15:28:06.000Z

@ghost ghost assigned jpellerin Dec 14, 2011
@jpellerin
Copy link
Member Author

This is much more complicated than I originally thought since this is how the
underlying unittest.py library does it.

For reference in 2.6 one can replace the implementation of
_TextTestResult.getDescription with an unconditional return str(test). But that of
course eliminates all choice and is not a suitable upstream change.

Google Code Info:
Author: [email protected]
Created On: 2010-01-25T20:22:36.000Z

@jpellerin
Copy link
Member Author

This simple plugin appears to fix it perfectly:
https://bitbucket.org/natw/nose-description-fixer-plugin/

Google Code Info:
Author: [email protected]
Created On: 2011-09-10T16:17:33.000Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant