testplan.runnable package

Subpackages

Submodules

testplan.runnable.base module

Tests runner module.

class testplan.runnable.base.TaskInformation(target: testplan.testing.base.Test | testplan.runners.pools.tasks.base.Task | Callable, materialized_test: testplan.testing.base.Test, uid: str)[source]

Bases: object

materialized_test: Test
target: Test | Task | Callable
uid: str
class testplan.runnable.base.TestRunner(**options)[source]

Bases: Runnable

Adds tests to test executor resources and invoke report exporter objects to create the TestRunnerResult.

Parameters:
  • name (str) – Name of test runner.

  • description (str) – Description of test runner.

  • logger_level (int) – Logger level for stdout.

  • runpath (str or callable) – Input runpath.

  • path_cleanup (bool) – Clean previous runpath entries.

  • all_tasks_local (bool) – Schedule all tasks in local pool

  • shuffle (list of str) – Shuffle strategy.

  • shuffle_seed (float) – Shuffle seed.

  • exporters (list) – Exporters for reports creation.

  • stdout_style (Style) – Styling output options.

  • report_dir (str) – Report directory.

  • xml_dir (str) – XML output directory.

  • pdf_path (str) – PDF output path <PATH>/*.pdf.

  • json_path (str) – JSON output path <PATH>/*.json.

  • pdf_style (Style) – PDF creation styling options.

  • http_url (str) – Web url for posting test report.

  • report_tags (list) – Matches tests marked with any of the given tags.

  • report_tags_all (list) – Match tests marked with all of the given tags.

  • merge_scheduled_parts (bool) – Merge report of scheduled MultiTest parts.

  • browse (bool or NoneType) – Open web browser to display the test report.

  • ui_port (int or NoneType) – Port of web server for displaying test report.

  • web_server_startup_timeout (int) – Timeout for starting web server.

  • test_filter (Subclass of BaseFilter) – Tests filtering class.

  • test_sorter (Subclass of BaseSorter) – Tests sorting class.

  • test_lister (Subclass of BaseLister) – Tests listing class.

  • verbose (bool) – Enable or disable verbose mode.

  • debug (bool) – Enable or disable debug mode.

  • timeout (NoneType or int (greater than 0).) – Timeout value for test execution.

  • abort_wait_timeout (int) – Timeout for test runner abort.

  • interactive_handler (Subclass of :py:class: TestRunnerIHandler <testplan.runnable.interactive.base.TestRunnerIHandler>) – Handler for interactive mode execution.

  • extra_deps (list of module or str) – Extra module dependencies for interactive reload, or paths of these modules.

  • label (str or NoneType) – Label the test report with the given name, useful to categorize or classify similar reports .

  • runtime_data (dict) – Historical runtime data which will be used for Multitest auto-part and weight-based Task smart-scheduling

  • auto_part_runtime_limit (int or float) – The runtime limitation for auto-part task

  • plan_runtime_target (int or float) – The testplan total runtime limitation for smart schedule

Param:

file_log_level: Logger level for file.

Also inherits all Runnable options.

CONFIG

alias of TestRunnerConfig

RESULT

alias of TestRunnerResult

STATUS

alias of TestRunnerStatus

abort_dependencies()[source]

Yield all dependencies to be aborted before self abort.

aborting()[source]

Stop the web server if it is running.

add(target: Test | Task | Callable, resource: str | None = None) str | None[source]

Adds a runnable test entity, or a Task, or a callable that returns a test entity to a Executor resource.

Parameters:
  • target (Runnable or Task or callable) – Test target.

  • resource (str or NoneType) – Name of the target executor, which is usually a Pool, default value None indicates using local executor.

Returns:

Assigned uid for test.

Return type:

str or `NoneType

add_environment(env: EnvironmentCreator, resource: Environments | None = None)[source]

Adds an environment to the target resource holder.

Parameters:
Returns:

Environment uid.

Return type:

str

add_exporters(exporters: List[BaseExporter])[source]

Add a list of report exporters for outputting test report.

Parameters:

exporters (list of Executor) – Test exporters to be added.

add_main_batch_steps()[source]

Runnable steps to be executed while resources are running.

add_post_resource_steps()[source]

Runnable steps to be executed after resources stopped.

add_pre_resource_steps()[source]

Runnable steps to be executed before resources started.

add_remote_service(remote_service: RemoteService)[source]

Adds a remote service RemoteService object to test runner.

Parameters:
  • remote_service – RemoteService object

  • remote_serviceRemoteService

add_resource(resource: Resource, uid: str | None = None) str[source]

Adds a test executor resource in the test runner environment.

Parameters:
  • resource – Test executor to be added.

  • uid – Optional input resource uid. We now force its equality with resource’s own uid.

Returns:

Resource uid assigned.

calculate_pool_size() None[source]

Calculate the right size of the pool based on the weight (runtime) of the tasks, so that runtime of all tasks meets the plan_runtime_target.

calculate_pool_size_by_tasks(tasks: Collection[Task]) int[source]

Calculate the right size of the pool based on the weight (runtime) of the tasks, so that runtime of all tasks meets the plan_runtime_target.

disable_reset_report_uid()[source]

Do not generate unique strings in uuid4 format as report uid

discard_pending_tasks(exec_selector: Expr, report_status: Status = Status.NONE, report_reason: str = '')[source]
discover(path: str = '.', name_pattern: str | Pattern = '.*\\.py$') List[Task][source]

Discover task targets under path in the modules that matches name pattern, and return the created Task object.

Parameters:
  • path – the root path to start a recursive walk and discover, default is current directory.

  • name_pattern – a regex pattern to match the file name.

Returns:

A list of Task objects

property exporters

Return a list of report exporters.

get_default_exporters()[source]

Instantiate certain exporters if related cmdline argument (e.g. –pdf) or programmatic arguments (e.g. pdf_path) is passed but there are not any exporter declarations.

get_test_metadata()[source]
static get_testplan_version()[source]
make_runpath_dirs()[source]

Creates runpath related directories.

property report: TestReport

Tests report.

run()[source]

Executes the defined steps and populates the result object.

schedule(task: Task | None = None, resource: str | None = None, **options) str | None[source]

Schedules a serializable Task in a task runner Pool executor resource.

Parameters:
  • task (Task) – Input task, if it is None, a new Task will be constructed using the options parameter.

  • resource (str or NoneType) – Name of the target executor, which is usually a Pool, default value None indicates using local executor.

  • options (dict) – Task input options.

Return uid:

Assigned uid for task.

Return type:

str or NoneType

schedule_all(path: str = '.', name_pattern: str | Pattern = '.*\\.py$', resource: str | None = None)[source]

Discover task targets under path in the modules that matches name pattern, create task objects from them and schedule them to resource (usually pool) for execution.

Parameters:
  • path (str) – the root path to start a recursive walk and discover, default is current directory.

  • name_pattern (str) – a regex pattern to match the file name.

  • resource (str or NoneType) – Name of the target executor, which is usually a Pool, default value None indicates using local executor.

uid()[source]

Entity uid.

class testplan.runnable.base.TestRunnerConfig(**options)[source]

Bases: RunnableConfig

Configuration object for TestRunner runnable object.

classmethod get_options()[source]

Runnable specific config options.

ignore_extra_keys = True
class testplan.runnable.base.TestRunnerResult[source]

Bases: RunnableResult

Result object of a TestRunner runnable object.

property success

Run was successful.

class testplan.runnable.base.TestRunnerStatus[source]

Bases: RunnableStatus

Status of a TestRunner runnable object.

testplan.runnable.base.collate_for_merging(es: List[TestGroupReport | TestCaseReport]) List[List[TestGroupReport | TestCaseReport]][source]

Group report entries into buckets, where synthesized ones in the same bucket containing the previous non-synthesized one.

testplan.runnable.base.get_exporters(values)[source]

Validation function for exporter declarations.

Parameters:

values – Single or a list of exporter declaration(s).

Returns:

List of initialized exporter objects.

testplan.runnable.base.result_for_failed_task(original_result)[source]

Create a new result entry for invalid result retrieved from a resource.

testplan.runnable.base.validate_lines(d: dict) bool[source]

Module contents