testplan.runnable package¶
Subpackages¶
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 reportexporter
objects to create theTestRunnerResult
.Parameters: - name (
str
) – Name of test runner. - description (
str
) – Description of test runner. - logger_level (
int
) – Logger level for stdout. - runpath (
str
orcallable
) – Input runpath. - path_cleanup (
bool
) – Clean previous runpath entries. - all_tasks_local (
bool
) – Schedule all tasks in local pool - shuffle (
list
ofstr
) – 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
orNoneType
) – Open web browser to display the test report. - ui_port (
int
orNoneType
) – 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
orint
(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
ofmodule
orstr
) – Extra module dependencies for interactive reload, or paths of these modules. - label (
str
orNoneType
) – 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
orfloat
) – The runtime limitation for auto-part task - plan_runtime_target (
int
orfloat
) – 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
-
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 aTask
, or a callable that returns a test entity to aExecutor
resource.Parameters: 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: - env (Subclass of
EnvironmentCreator
) – Environment creator instance. - resource (Subclass of
Environments
) – Target environments holder resource.
Returns: Environment uid.
Return type: str
- env (Subclass of
-
add_exporters
(exporters: List[testplan.common.exporters.BaseExporter])[source]¶ Add a list of
report exporters
for outputting test report.Parameters: exporters ( list
ofExecutor
) – Test exporters to be added.
-
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_service –
RemoteService
-
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.
-
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.
-
report
¶ Tests report.
-
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 runnerPool
executor resource.Parameters: - task (
Task
) – Input task, if it is None, a new Task will be constructed using the options parameter. - resource (
str
orNoneType
) – 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
orNoneType
- task (
-
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
orNoneType
) – Name of the target executor, which is usually a Pool, default value None indicates using local executor.
- path (
- name (
-
class
testplan.runnable.base.
TestRunnerConfig
(**options)[source]¶ Bases:
testplan.common.entity.base.RunnableConfig
Configuration object for
TestRunner
runnable object.-
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.