8000 bpo-30181: parse docstring using pydoc by brianmay · Pull Request #1505 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-30181: parse docstring using pydoc #1505

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

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add test cases for single-line test case docstring.
  • Loading branch information
benf-wspdigital authored and Brian May committed May 9, 2017
commit e77fa7afc53e5035765751cf894dfb5d452cb53b
20 changes: 12 additions & 8 deletions Lib/unittest/test/test_functiontestcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,27 @@ def test_id(self):

self.assertIsInstance(test.id(), str)

# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
# the first line of the test method's docstring, if available, or None."
def test_shortDescription__no_docstring(self):
def test_shortDescription__no_description_no_docstring(self):
""" Should return None by default for shortDescription. """
test = unittest.FunctionTestCase(lambda: None)

self.assertEqual(test.shortDescription(), None)

# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
# the first line of the test method's docstring, if available, or None."
def test_shortDescription__singleline_docstring(self):
def test_shortDescription__singleline_description(self):
""" Should use the specified description for shortDescription. """
desc = "this tests foo"
test = unittest.FunctionTestCase(lambda: None, description=desc)

self.assertEqual(test.shortDescription(), "this tests foo")

def test_shortDescription__no_description_singleline_docstring(self):
""" Should use the function docstring for the shortDescription. """
test_function = (lambda: None)
test_function.__doc__ = """Should use the function docstring."""
test = unittest.FunctionTestCase(test_function)
expected_description = "Should use the function docstring."
self.assertEqual(test.shortDescription(), expected_description)


if __name__ == "__main__":
unittest.main()
0