5
2

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.

Integrating with setuptools / python setup.py test / pytest-runner

Last updated at Posted at 2016-09-27

pytestお勉強の続き。公式ドキュメントや逆引きpytestを参考に試しています。

pytestを、以下のコマンドで実行できるようにします。やり方はここに書いてある通りです。

python setup.py test

setup.pyファイルに設定を追加します。coverageのプラグインも入れています。

setup.py
setup_requires = [
    'pytest-runner',
    ]

tests_require = [
    'pytest-cov',
    'pytest',
    ]

setup( # 一部を抜粋
      setup_requires=setup_requires,
      tests_require=tests_require,
      )

setup.cfgファイルに設定を追加します。coverageやテストにかかった時間を表示するオプションを設定しています。

setup.cfg
[aliases]
test=pytest

[tool:pytest]
addopts = --verbose --durations=0 --cov=app --cov-report=html
testpaths = tests
python_files = *.py

参考

5
2
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
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?