session
A plugin that implements the core logic of running Testwizard tests in the pytest ecosystem.
It consists of two plugins:
the session.py module, which is responsible for initializing the TestWizardSession plugin,
and the TestWizardSession plugin itself, which handles the lifecycle of tests and fixtures.
TestWizardSession #
pytest_collection_finish #
Stores some metadata about the collected tests as follows:
- Dumps info.json after test collection
- Collect mapping item.nodeid -> metadata.uid. Then store this uid in the item stash. * It allows to load test metadata from item.stash[stash_keys.TEST_ITEM_UID].
Since xdist plugin performs collection on each worker, we are forced to use file locking to prevent collisions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
|
required |
pytest_collection_modifyitems
staticmethod
#
pytest_tw_run_fixture_protocol
staticmethod
#
pytest_tw_run_fixture_protocol(
fixt_def: FixtureSpec,
metadata: FixtureMetadata,
config: Config,
) -> bool
Basic logic of fixture running
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fixt_def
|
FixtureSpec
|
description |
required |
metadata
|
FixtureMetadata
|
description |
required |
config
|
Config
|
description |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
a flag indicating whether an error occurred or not during test run |
pytest_tw_run_test_item_protocol
staticmethod
#
Basic logic of test running
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item
|
Item
|
test item |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
a flag indicating whether an error occurred or not during test run |
pytest_tw_teardown_test_item #
parametrize #
parametrize(
metafunc: Metafunc,
argnames: str | Sequence[str],
argvalues: Iterable[Any],
indirect: bool = False,
) -> None
Get pytest.Metafunc and parametrize item through it.
Using the indirect=True allows to parametrize a test with a fixture receiving the values before passing them to a test
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metafunc
|
Metafunc
|
metafunc object |
required |