pytestで1ファイル/1テストだけ実行したい(他よく使うオプション)
pytest実行時に便利なオプションを書いた備忘録です。
前提条件
例で出てくるプロジェクトのイメージ
pj_root(カレントディレクトリ)
├..
└tests
├..
└test_example.py
例で登場するtest_example.py
のイメージ
test_example.py
import unittest
class TestExample(unittest.TestCase):
def test_example_ok_pattern(self):
actual = True
expected = True
assert actual == expected
1ファイル/1テストだけ実行したい
1ファイルだけ実行する
pytest (path)
# 例
pytest tests/test_exapmle.py
1テストだけ実行する
pytest (path)::(TestClass)::(test_method)
pytest (path)::(test_method)
# 例
pytest tests/test_exapmle.py::TestExample::test_example_ok_pattern
その他、よく使うオプション
最後にコケたテストだけ実行する
pytest --lf
テストが1つでもコケたらそこでテスト実行を止める
pytest -x
テストがコケた時に結果を詳細に表示する
pytest -vv
Author And Source
この問題について(pytestで1ファイル/1テストだけ実行したい(他よく使うオプション)), 我々は、より多くの情報をここで見つけました https://qiita.com/jesus_isao/items/f69e89ea175bd02ea1cf著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .