I have a pytest module with the below test functions with doc strings, then when I run the pytest , I want the doc string to be displayed in the command line for each test run so that it will have clear view of the test case. eg:-
test_module.py:-
def test_add():
'''
This is a test function for adding two numbers
'''
expected_ouput= 10
actual_output = x.add(1,9)
assert expected_output == actual_output
def test_sub():
'''
This is a test function for subtracting two numbers
'''
expected_ouput= 1
actual_output = x.sub(1,9)
assert expected_output == actual_output
>pytest
Output:-
====================================================================== test session starts =======================================================================
platform darwin -- Python 3.6.4, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /Users/deepak/PycharmProjects/test_projects, inifile:
collected 3 items
tests/test_module.py .
--
test_add
This is a test function for adding two numbers [ 33%]
--
test_sub
This is a test function for subtracting two numbers
[100%]
=================================================================== 2 passed in 19.78 seconds ====================================================================
How to do this ?