arjuna.engine.pytest module¶
- class arjuna.engine.pytest.PytestHooks¶
Bases:
object
Easy hooks to be used in pytest configuration file: conftest.py placed under <Project_Root_Dir/test directory in test project.
- classmethod add_env_data(config)¶
- classmethod configure_group_for_test(metafunc)¶
Configures group fixture for a test.
Acts only if group fixture is present in the signature of a test function or signature(s) of any of its fixture(s) in its fixture hierarchy.
To be used in pytest_generate_tests hook in conftest.py.
- Parameters
metafunc – pytest’s MetaFunc object
Note
- The group fixture yields a DataRecord object containing the following keys:
name: Group name
config: Configuration object assigned to the group.
thread_name: Thread name for the thread in which the Test Group is running.
- classmethod enhance_reports(item, result)¶
Automatically add screenshot to HTML Report File.
To be used in pytest_runtest_makereport hook in conftest.py.
- Parameters
item – pytest’s Item object
result – pytest’s TestReport object.
Note
- For taking the screenshot, it does a look up for a screen_shooter attribute in the object spaces in following order:
Function Space
Module Space
Session Space
The screen_shooter attribute should contain a ScreenShooter i.e. an object of a class that inherits from ScreenShooter class and completes its protocol.
This is a lenient hook. This means that if any exception happens in it, it ignores the exception and logs a warning message.
- classmethod inject_arjuna_js(prefix)¶
- classmethod prepare_result(result)¶
- classmethod select_tests(pytest_items, pytest_config)¶
Select tests from items collected by pytest, based on Arjuna rules.
- Parameters
pytest_items – List of pytest Item objects. Each item represents a collected test function node.
pytest_config – pytest Config object
- classmethod set_report_title(report)¶