testplan.runnable package

Submodules

testplan.runnable.base module

Tests runner module.

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

Bases: object

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

Bases: testplan.common.entity.base.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.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: Union[testplan.testing.base.Test, testplan.runners.pools.tasks.base.Task, Callable], resource: Optional[str] = None) → Optional[str][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: testplan.environment.EnvironmentCreator, resource: Optional[testplan.environment.Environments] = None)[source]

Adds an environment to the target resource holder.

Parameters:
Returns:

Environment uid.

Return type:

str

add_exporters(exporters: List[testplan.common.exporters.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: testplan.common.remote.remote_service.RemoteService)[source]

Adds a remote service RemoteService object to test runner.

Parameters:
  • remote_service – RemoteService object
  • remote_serviceRemoteService
add_resource(resource: testplan.common.entity.base.Resource, uid: Optional[str] = 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[testplan.runners.pools.tasks.base.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: testplan.report.testing.base.Status = <Status.NONE: 59>, report_reason: str = '')[source]
discover(path: str = '.', name_pattern: Union[str, Pattern[AnyStr]] = '.*\\.py$') → List[testplan.runners.pools.tasks.base.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

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]
make_runpath_dirs()[source]

Creates runpath related directories.

report

Tests report.

run()[source]

Executes the defined steps and populates the result object.

schedule(task: Optional[testplan.runners.pools.tasks.base.Task] = None, resource: Optional[str] = None, **options) → Optional[str][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: Union[str, Pattern[AnyStr]] = '.*\\.py$', resource: Optional[str] = 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: testplan.common.entity.base.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: testplan.common.entity.base.RunnableResult

Result object of a TestRunner runnable object.

report

Tests report.

success

Run was successful.

class testplan.runnable.base.TestRunnerStatus[source]

Bases: testplan.common.entity.base.RunnableStatus

Status of a TestRunner runnable object.

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