Created
July 7, 2009 09:17
-
-
Save FND/141977 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: py/test/plugin/pytest_terminal.py | |
| =================================================================== | |
| --- py/test/plugin/pytest_terminal.py (revision 66152) | |
| +++ py/test/plugin/pytest_terminal.py (working copy) | |
| @@ -284,6 +284,11 @@ | |
| except AttributeError: | |
| pass | |
| reportinfo = item.config.hook.pytest_report_iteminfo(item=item) | |
| + # add docstring to message | |
| + docstring = item.obj.__doc__ # TODO: shorten | |
| + reportinfo = list(reportinfo) # mutable type required -- XXX: hacky | |
| + reportinfo[-1] = "%s: %s" % (reportinfo[-1], docstring) | |
| + reportinfo = tuple(reportinfo) | |
| # cache on item | |
| item.__reportinfo = reportinfo | |
| return reportinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| py.test: using docstrings for test descriptions | |
| """ | |
| def test_foo(): | |
| """lorem ipsum""" | |
| actual = True | |
| expected = True | |
| assert actual == expected | |
| def test_bar(): | |
| """dolor sit amet""" | |
| actual = True | |
| expected = True | |
| assert actual == expected | |
| def test_baz(): | |
| """consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" | |
| actual = False | |
| expected = True | |
| assert actual == expected | |
| ''' | |
| == Expected Output == | |
| default (no change): | |
| test_case.py ..F | |
| verbose (added docstring, possibly truncated, perhaps using ellipses in the middle): | |
| test_case.py:6: test_foo PASS lorem ipsum | |
| test_case.py:13: test_bar PASS dolor sit amet | |
| test_case.py:20: test_baz FAIL consectetur adipisic...liqua | |
| failure (added full docstring -- N.B.: might seem redundant, but isn't for long test functions): | |
| def test_baz(): | |
| """consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" | |
| actual = False | |
| expected = True | |
| > assert actual == expected | |
| E assert False == True | |
| test_case.py:24: AssertionError | |
| consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua | |
| == Actual Output == | |
| $ py.test -v test/test_case.py | |
| ==================================================== test session starts ==================================================== | |
| python: platform linux2 -- Python 2.5.2 -- /usr/bin/python -- pytest-1.0.0b6 | |
| test object 1: /tmp/py.test/trunk/test/test_case.py | |
| test/test_case.py:5: test_foo: lorem ipsum PASS | |
| test/test_case.py:12: test_bar: dolor sit amet PASS | |
| test/test_case.py:19: test_baz: consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua FAIL | |
| ========================================================= FAILURES ========================================================== | |
| _________ test_baz: consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua _________ | |
| def test_baz(): | |
| """consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua""" | |
| actual = False | |
| expected = True | |
| > assert actual == expected | |
| E assert False == True | |
| /tmp/py.test/trunk/test/test_case.py:23: AssertionError | |
| ============================================ 1 failed, 2 passed in 0.13 seconds ============================================= | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this does not work in pytest-2.7.0, any specific flag need to use?