|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
| 3 | +from collections.abc import Callable |
| 4 | + |
3 | 5 | import pytest |
| 6 | +from _pytest.fixtures import FixtureRequest |
| 7 | + |
| 8 | +from pytest_bdd.parser import Feature, Scenario, Step |
4 | 9 |
|
5 | 10 | """Pytest-bdd pytest hooks.""" |
6 | 11 |
|
7 | 12 |
|
8 | | -def pytest_bdd_before_scenario(request, feature, scenario): |
| 13 | +def pytest_bdd_before_scenario(request: FixtureRequest, feature: Feature, scenario: Scenario) -> object: |
9 | 14 | """Called before scenario is executed.""" |
10 | 15 |
|
11 | 16 |
|
12 | | -def pytest_bdd_after_scenario(request, feature, scenario): |
| 17 | +def pytest_bdd_after_scenario(request: FixtureRequest, feature: Feature, scenario: Scenario) -> object: |
13 | 18 | """Called after scenario is executed.""" |
14 | 19 |
|
15 | 20 |
|
16 | | -def pytest_bdd_before_step(request, feature, scenario, step, step_func): |
| 21 | +def pytest_bdd_before_step( |
| 22 | + request: FixtureRequest, feature: Feature, scenario: Scenario, step: Step, step_func: Callable[..., object] |
| 23 | +) -> object: |
17 | 24 | """Called before step function is set up.""" |
18 | 25 |
|
19 | 26 |
|
20 | | -def pytest_bdd_before_step_call(request, feature, scenario, step, step_func, step_func_args): |
| 27 | +def pytest_bdd_before_step_call( |
| 28 | + request: FixtureRequest, |
| 29 | + feature: Feature, |
| 30 | + scenario: Scenario, |
| 31 | + step: Step, |
| 32 | + step_func: Callable[..., object], |
| 33 | + step_func_args: dict[str, object], |
| 34 | +) -> object: |
21 | 35 | """Called before step function is executed.""" |
22 | 36 |
|
23 | 37 |
|
24 | | -def pytest_bdd_after_step(request, feature, scenario, step, step_func, step_func_args): |
| 38 | +def pytest_bdd_after_step( |
| 39 | + request: FixtureRequest, |
| 40 | + feature: Feature, |
| 41 | + scenario: Scenario, |
| 42 | + step: Step, |
| 43 | + step_func: Callable[..., object], |
| 44 | + step_func_args: dict[str, object], |
| 45 | +) -> object: |
25 | 46 | """Called after step function is successfully executed.""" |
26 | 47 |
|
27 | 48 |
|
28 | | -def pytest_bdd_step_error(request, feature, scenario, step, step_func, step_func_args, exception): |
| 49 | +def pytest_bdd_step_error( |
| 50 | + request: FixtureRequest, |
| 51 | + feature: Feature, |
| 52 | + scenario: Scenario, |
| 53 | + step: Step, |
| 54 | + step_func: Callable[..., object], |
| 55 | + step_func_args: dict[str, object], |
| 56 | + exception: Exception, |
| 57 | +) -> object: |
29 | 58 | """Called when step function failed to execute.""" |
30 | 59 |
|
31 | 60 |
|
32 | | -def pytest_bdd_step_func_lookup_error(request, feature, scenario, step, exception): |
| 61 | +def pytest_bdd_step_func_lookup_error( |
| 62 | + request: FixtureRequest, feature: Feature, scenario: Scenario, step: Step, exception: Exception |
| 63 | +) -> object: |
33 | 64 | """Called when step lookup failed.""" |
34 | 65 |
|
35 | 66 |
|
36 | 67 | @pytest.hookspec(firstresult=True) |
37 | | -def pytest_bdd_apply_tag(tag, function): |
| 68 | +def pytest_bdd_apply_tag(tag: str, function: Callable[..., object]) -> object: |
38 | 69 | """Apply a tag (from a ``.feature`` file) to the given scenario. |
39 | 70 |
|
40 | 71 | The default implementation does the equivalent of |
|
0 commit comments