Skip to content

New Est Shizard hooks

Est Shizard new hooks specification. All new hooks must be prefixed with pytest_esh.

pytest_tw_modify_test_item_context #

pytest_tw_modify_test_item_context(item: Item) -> None

Called during pytest_tw_setup_test_item to modify a test item context in the stash if needed.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_prepare_report_metadata #

pytest_tw_prepare_report_metadata(
    item: Item,
) -> dict | None

Called during pytest_runtest_makereport to prepare a test item report metadata.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

Returns:

Type Description
dict | None

dict | None: test item report metadata dict or None

pytest_tw_prepare_test_item_env #

pytest_tw_prepare_test_item_env(item: Item) -> dict | None

Called during pytest_tw_setup_test_item to prepare a test item environment variables.

This env will be stashed in test item context.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

Returns:

Type Description
dict | None

dict | None: test item environment variables dict or None

pytest_tw_prepare_test_item_repro_script #

pytest_tw_prepare_test_item_repro_script(item: Item) -> str

Called during pytest_tw_setup_test_item to prepare a test item reproduction script.

The generated script will then be saved to a file.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

Returns:

Name Type Description
str str

A test item reproduction script

pytest_tw_run_fixture #

pytest_tw_run_fixture(
    fixt_def: FixtureSpec, metadata: FixtureMetadata
) -> object | None

By default, Est Shizard currently uses the script_runner plugin to implement this hook.

Parameters:

Name Type Description Default
fixt_def FixtureSpec

fixture definition

required
metadata FixtureMetadata

fixture metadata

required

pytest_tw_run_fixture_form_assertion_message #

pytest_tw_run_fixture_form_assertion_message(
    fixt_def: FixtureSpec, run_report: RunReport
) -> str | None

Called during pytest_tw_run_fixture to prepare a custom test item error message.

Parameters:

Name Type Description Default
fixt_def FixtureSpec

fixture definition

required
run_report RunReport

(RunReport): run result

required

Returns:

Type Description
str | None

str | None: test item report metadata str or None

pytest_tw_run_fixture_process_artifacts #

pytest_tw_run_fixture_process_artifacts(
    fixt_def: FixtureSpec, run_success: bool
) -> None

Called during pytest_tw_run_fixture_protocol to perform artifacts processing

Parameters:

Name Type Description Default
fixt_def FixtureSpec

fixture definition

required
run_success bool

run success marker

required

pytest_tw_run_fixture_process_log #

pytest_tw_run_fixture_process_log(
    fixt_def: FixtureSpec,
    metadata: FixtureMetadata,
    config: Config,
) -> None

Called during pytest_tw_run_fixture_protocol to perform log processing

Parameters:

Name Type Description Default
fixt_def FixtureSpec

fixture definition

required
config Config

pytest.Config object

required
metadata FixtureMetadata

fixture metadata

required

pytest_tw_run_fixture_protocol #

pytest_tw_run_fixture_protocol(
    fixt_def: FixtureSpec,
    metadata: FixtureMetadata,
    config: Config,
) -> object | None

Called during exec_fixture from the FixtureCaller

Stops at first non-None result, see firstresult. The return value is not used, but only stops further processing.

Parameters:

Name Type Description Default
fixt_def FixtureSpec

fixture definition

required
metadata FixtureMetadata

fixture metadata

required
config Config

description

required

pytest_tw_run_test #

pytest_tw_run_test(item: Item) -> object | None

Called during pytest_tw_run_test_item_protocol to run the test for test item

Stops at first non-None result, see firstresult. The return value is not used, but only stops further processing.

By default, Est Shizard currently uses the script_runner plugin to implement this hook.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_run_test_form_assertion_message #

pytest_tw_run_test_form_assertion_message(
    item: Item, run_report: RunReport
) -> str | None

Called during pytest_tw_run_test to prepare a custom test item error message.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required
run_report RunReport

(RunReport): run result

required

Returns:

Type Description
str | None

str | None: test item report metadata str or None

pytest_tw_run_test_item_protocol #

pytest_tw_run_test_item_protocol(
    item: Item,
) -> object | None

Called during pytest_runtest_call from the test item description to perform the Est Shizard's protocol for a single test item.

Stops at first non-None result, see firstresult. The return value is not used, but only stops further processing. Used for

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_run_test_process_artifacts #

pytest_tw_run_test_process_artifacts(
    item: Item, run_success: bool
) -> None

Called during pytest_tw_run_test_item_protocol to perform artifacts processing

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required
run_success bool

run success marker

required

pytest_tw_run_test_process_log #

pytest_tw_run_test_process_log(
    item: Item, config: Config
) -> None

Called during pytest_tw_run_test_item_protocol to perform log processing

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_setup_test_item #

pytest_tw_setup_test_item(item: Item) -> None

Called during pytest.pytest_runtest_setup to perform the setup phase for Est Shizard test item

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_setup_test_item_env #

pytest_tw_setup_test_item_env(item: Item) -> None

Called during pytest_tw_setup_test_item to inject a test item environment variables in the environment.

The default implementation uses a pytest.MonkeyPatch object stashed in a test item context to setup each variable.

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required

pytest_tw_teardown_test_item #

pytest_tw_teardown_test_item(item: Item) -> None

Called during pytest_runtest_teardown to perform the teardown phase for Est Shizard test item

Parameters:

Name Type Description Default
item Item

pytest.Item object of current test

required