feat: 一気通貫テストだけを実行するためのマーカーとコマンドを追加

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2022-08-19 12:00:26 +09:00
parent 9a511af10b
commit 40aca22a33
3 changed files with 28 additions and 0 deletions

View File

@ -7,6 +7,7 @@ name = "pypi"
test = "pytest tests/"
"test:cov" = "pytest --cov=src --cov-branch --cov-report=term-missing tests/"
"test:report" = "pytest --cov=src --cov-branch --cov-report=term-missing --html=.report/test_result.html tests/"
"test:walk-through" = "pytest tests/ --walk-through"
[packages]
boto3 = "*"

View File

@ -57,3 +57,23 @@ def pytest_runtest_makereport(item, call):
report.cases = docstring.get("Cases", '') # 「テスト内容」を`report`に追加
report.arranges = docstring.get("Arranges", '') # 「準備作業」を`report`に追加
report.expects = docstring.get("Expects", '') # 「期待結果」を`report`に追加
def pytest_addoption(parser):
parser.addoption(
"--walk-through", action="store_true", default=False, help="run walk through tests"
)
def pytest_configure(config):
config.addinivalue_line("markers", "slow: mark test as slow to run")
def pytest_collection_modifyitems(config, items):
skip_slow = pytest.mark.skip(reason="need --walk-through option to run")
if config.getoption("--walk-through"):
[item.add_marker(skip_slow) for item in items if "walk_through" not in item.keywords]
return
for item in items:
if "walk_through" in item.keywords:
item.add_marker(skip_slow)

View File

@ -0,0 +1,7 @@
import pytest
@pytest.mark.walk_through
def test_walk_through():
assert 0
pass