How to use pytest_report_header

I started using pytest. I'm too new to me and I still don't understand.

I want to put a header in the test result

I intend to write according to Adding info to test report header However, nothing was displayed in the test results.

tests.py


def pytest_report_header(config):
    return "sample: functional tests"

The reason why the header is not displayed was because I wrote the above code in a file with test code. If you read the docs properly, you have to write it in a file called conftest.py, as it says # content of conftest.py.

conftest.py


def pytest_report_header(config):
    return "sample: functional tests"
# py.test -v tests.py
====================================================== test session starts ======================================================
platform linux -- Python 3.5.1, pytest-3.0.2, py-1.4.31, pluggy-0.3.1 -- /home/app/.pyenv/versions/3.5.1/bin/python3.5
cachedir: .cache
sample: functional tests
rootdir: /home/app, inifile: 
plugins: cov-2.3.1
collected 2 items 

tests.py::FunctionalTests::test_not_found PASSED
tests.py::FunctionalTests::test_resize_to_half PASSED

=================================================== 2 passed in 9.56 seconds ====================================================

Recommended Posts

How to use pytest_report_header
How to use xml.etree.ElementTree
How to use Python-shell
How to use tf.data
How to use virtualenv
How to use Seaboan
How to use image-match
How to use shogun
How to use Pandas 2
How to use Virtualenv
How to use numpy.vectorize
How to use partial
How to use Bio.Phylo
How to use SymPy
How to use x-means
How to use WikiExtractor.py
How to use IPython
How to use virtualenv
How to use Matplotlib
How to use iptables
How to use numpy
How to use TokyoTechFes2015
How to use venv
How to use dictionary {}
How to use Pyenv
How to use list []
How to use python-kabusapi
How to use OptParse
How to use return
How to use dotenv
How to use pyenv-virtualenv
How to use Go.mod
How to use imutils
How to use import
How to use Qt Designer
[gensim] How to use Doc2Vec
python3: How to use bottle (2)
Understand how to use django-filter
How to use the generator
[Python] How to use list 1
How to use FastAPI ③ OpenAPI
How to use Python argparse
How to use IPython Notebook
How to use Pandas Rolling
[Note] How to use virtualenv
How to use redis-py Dictionaries
Python: How to use pydub
[Python] How to use checkio
[Go] How to use "... (3 periods)"
How to use Django's GeoIp2
[Python] How to use input ()
How to use the decorator
[Introduction] How to use open3d
How to use Python lambda
How to use Jupyter Notebook
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Google Colaboratory
How to use Python bytes
How to use cron (personal memo)