New issue 445: Use test function docstrings to provide nicer names for tests
https://bitbucket.org/hpk42/pytest/issue/445/use-test-function-docstrings-to-provide

Thomas Winwood:

I wrote some tests...
```
#!python

def test_empty():
    tokens = lexer.lex("")
    with pytest.raises(StopIteration):
        assert next(tokens)

def test_space():
    tokens = lexer.lex(" ")
    assert next(tokens) == Token("SPACE", " ")

def test_tab():
    tokens = lexer.lex("\t")
    assert next(tokens) == Token("TAB", "\t")

def test_newline():
    tokens = lexer.lex("\n")
    assert next(tokens) == Token("NEWLINE", "\n")
```
...and it occurred to me that I could provide docstrings for these functions so 
the error output when a test fails looks a little friendlier and in some cases 
is more descriptive than the function name (which tends to be a little terse by 
necessity).  Is this possible, or is there some functionality which already 
uses the docstring of test functions for something else?


_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to