Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

cucumberjson compatibility with pytest-timeout

オープン
#770 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
testing

調査の方向性

tests/test_timeout.py、timeout.feature、pytest-timeout、および示されているコマンドを使ってケースを再現し、その後、生成されたoutput.jsonを調べます。タイムアウトしたステップがどのように記録されるかを追跡し、cucumberjsonの結果に失敗が反映されるようにします。出力でそのステップが合格として報告されなくなっていることを確認します。

索引モデルが issue の本文から書いたものです。

説明

This isn't truly an issue with pytest-bdd, but I thought this was worth mentioning given the popularity of the pytest-timeout plugin.

I noticed that if the pytest-timeout plugin is used, it can correctly fail a scenario, but all steps show as passed in the cucumberjson output. A minimal example:

test_timeout.py:

from pytest_bdd import scenario, when
import time

@scenario('timeout.feature', 'Long running operation')
def test_long_running():
    pass

@when('I wait for a really long time')
def wait_long_time():
    time.sleep(3)

timeout.feature:

Feature: Timeout demonstration
    Demonstration of a long-running operation

    Scenario: Long running operation
        When I wait for a really long time

then run pytest:

pytest -s tests/test_timeout.py --cucumberjson=output.json --timeout 1

to get the following logs:

=================================================================================================================================================== test session starts ====================================================================================================================================================
platform linux -- Python 3.12.7, pytest-8.3.5, pluggy-1.5.0
rootdir: /media/jason/e/pytest-bdd
configfile: pytest.ini
plugins: bdd-8.1.0, timeout-2.3.1
timeout: 1.0s
timeout method: signal
timeout func_only: False
collected 1 item                                                                                                                                                                                                                                                                                                           

tests/test_timeout.py OUTCOME: failed
F

========================================================================================================================================================= FAILURES =========================================================================================================================================================
____________________________________________________________________________________________________________________________________________________ test_long_running _____________________________________________________________________________________________________________________________________________________

fixturefunc = <function wait_long_time at 0x7130aa194360>, request = <FixtureRequest for <Function test_long_running>>, kwargs = {}

    def call_fixture_func(
        fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs
    ) -> FixtureValue:
        if is_generator(fixturefunc):
            fixturefunc = cast(
                Callable[..., Generator[FixtureValue, None, None]], fixturefunc
            )
            generator = fixturefunc(**kwargs)
            try:
                fixture_result = next(generator)
            except StopIteration:
                raise ValueError(f"{request.fixturename} did not yield a value") from None
            finalizer = functools.partial(_teardown_yield_fixture, fixturefunc, generator)
            request.addfinalizer(finalizer)
        else:
            fixturefunc = cast(Callable[..., FixtureValue], fixturefunc)
>           fixture_result = fixturefunc(**kwargs)

venv/lib/python3.12/site-packages/_pytest/fixtures.py:898: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    @when('I wait for a really long time')
    def wait_long_time():
>       time.sleep(3)
E       Failed: Timeout >1.0s

tests/test_timeout.py:10: Failed
------------------------------------------------------------------------------------------------------------------------- generated json file: /media/jason/e/pytest-bdd/output.json -------------------------------------------------------------------------------------------------------------------------
================================================================================================================================================= short test summary info ==================================================================================================================================================
FAILED tests/test_timeout.py::test_long_running - Failed: Timeout >1.0s

but the following output.json shows the step passed:

[
  {
    "keyword": "Feature",
    "uri": "tests/timeout.feature",
    "name": "Timeout demonstration",
    "id": "tests/timeout.feature",
    "line": 1,
    "description": "Demonstration of a long-running operation",
    "language": "en",
    "tags": [],
    "elements": [
      {
        "keyword": "Scenario",
        "id": "test_long_running",
        "name": "Long running operation",
        "line": 4,
        "description": "",
        "tags": [],
        "type": "scenario",
        "steps": [
          {
            "keyword": "When",
            "name": "I wait for a really long time",
            "line": 5,
            "match": {
              "location": ""
            },
            "result": {
              "status": "passed",
              "duration": 0
            }
          }
        ]
      }
    ]
  }
]

pytest==8.3.5
pytest-bdd==8.1.0
pytest-timeout==2.3.1

主要言語
Python
スター
1.5k
フォーク
251
平均マージ
43分
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pytest-dev/pytest-bdd のほかの issue

pytest-dev/pytest-bdd の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。