Pytest Verbose

verbose is an argument which is used to report more information about an operation in your program.

If we use the verbose argument “-v” while executing the pytest commands then it shows more detailed information in output data.

-v : Verbose

-s : To print statements on console 

test_PytestExample.py

def test_methodA():
    print("This is method A")


def test_methodB():
    print("This is method B")


def test_methodC():
    print("This is method C")


def test_methodD():
    print("This is method D")


1. Here we are executing above file test_PytestExample.py without using verbose argument “-v”

pytest test_PytestExample.py

OutPut data


admin@admin-MacBook pytestconcept % pytest test_PytestExample.py 
============================================================================ test session starts ============================================================================
platform darwin -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: /Users/admin/Documents/Skill2Lead/Tutorials/pytest/pytestconcept
plugins: rerunfailures-9.0, allure-pytest-2.8.16, ordering-0.6
collected 4 items                                                                                                                                                           

test_PytestExample.py ....                                                                                                                                            [100%]

============================================================================= 4 passed in 0.04s =============================================================================
admin@admin-MacBook pytestconcept % 


2. Now, We are executing along with the verbose argument “-v”. This will print the data about test cases which are passed and failed; it shows more detailed information in output data.

pytest -v test_PytestExample.py

OutPut data

admin@admin-MacBook pytestconcept % pytest -v test_PytestExample.py
============================================================================ test session starts ============================================================================
platform darwin -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
cachedir: .pytest_cache
rootdir: /Users/admin/Documents/Skill2Lead/Tutorials/pytest/pytestconcept
plugins: rerunfailures-9.0, allure-pytest-2.8.16, ordering-0.6
collected 4 items                                                                                                                                                           

test_PytestExample.py::test_methodA PASSED                                                                                                                            [ 25%]
test_PytestExample.py::test_methodB PASSED                                                                                                                            [ 50%]
test_PytestExample.py::test_methodC PASSED                                                                                                                            [ 75%]
test_PytestExample.py::test_methodD PASSED                                                                                                                            [100%]

============================================================================= 4 passed in 0.03s =============================================================================
admin@admin-MacBook pytestconcept % 



3. We are executing a file by using the statement “-s” argument,To show the difference.

Here '-s' is used to print the data in the console which is written in the script.

pytest -v -s test_PytestExample.py

OutPut data

admin@admin-MacBook pytestconcept % pytest -v -s test_PytestExample.py
============================================================================ test session starts ============================================================================
platform darwin -- Python 3.8.3, pytest-5.4.3, py-1.8.1, pluggy-0.13.1 -- /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8
cachedir: .pytest_cache
rootdir: /Users/admin/Documents/Skill2Lead/Tutorials/pytest/pytestconcept
plugins: rerunfailures-9.0, allure-pytest-2.8.16, ordering-0.6
collected 4 items                                                                                                                                                           

test_PytestExample.py::test_methodA This is method A
PASSED
test_PytestExample.py::test_methodB This is method B
PASSED
test_PytestExample.py::test_methodC This is method C
PASSED
test_PytestExample.py::test_methodD This is method D
PASSED

============================================================================= 4 passed in 0.02s =============================================================================
admin@admin-MacBook pytestconcept %