0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pytest_report_header の使い方

Last updated at Posted at 2016-09-26

pytestを使い始めました。初心者すぎて、まだ分からないことだらけです。

テスト結果にヘッダーを出したい

Adding info to test report headerに従って書いたつもりですが、テスト結果には何も表示されませんでした。

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

ヘッダーが表示されない原因は、上記のコードをテストコードがあるファイルに書いていたからでした。ドキュメントをちゃんと読めば、# content of conftest.pyとあるように、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 ====================================================
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?