testplan.runnable.interactive package

Submodules

testplan.runnable.interactive.base

Interactive handler for TestRunner runnable class.

class testplan.runnable.interactive.base.TestRunnerIHandler(target, startup_timeout=10, http_port=0, pre_start_environments=None)[source]

Bases: testplan.common.entity.base.Entity

Runnable interactive handler for TestRunner runnable object.

CONFIG

alias of TestRunnerIHandlerConfig

STATUS

alias of testplan.common.entity.base.RunnableStatus

abort_dependencies()[source]

Http service to be aborted at first.

aborting() → None[source]

Aborting step for the handler. Stops resources before thread is joined.

all_tests()[source]

Get all added tests.

all_tests_operation(operation, await_results=True)[source]

Perform an operation in all tests.

environment_resource_context(env_uid, resource_uid, context_item=None, **kwargs)[source]

Get the context info of an environment resource.

environment_resource_operation(env_uid, resource_uid, res_op, **kwargs)[source]

Perform an operation on an environment resource.

environment_resource_start(env_uid, resource_uid)[source]

Start an environment resource.

environment_resource_stop(env_uid, resource_uid)[source]

Stop an environment resource.

exit_code

Code to indicate success or failure.

exporters
get_environment(env_uid)[source]

Get an environment.

get_environment_context(env_uid, resource_uid=None, exclude_callables=True, exclude_protected=True, exclude_private=True)[source]

Get the context information of an environment.

get_environment_resource(env_uid, resource_uid)[source]

Get a resource from an environment.

http_handler_info
reload(rebuild_dependencies=False)[source]

Reload test suites.

reload_report()[source]

Update report with added/removed testcases

reset_all_tests(await_results=True)[source]

Reset the Testplan report.

Parameters:await_results – Whether to block until tests are finished, defaults to True.
Returns:If await_results is True, returns a testplan report. Otherwise, returns a future which will yield a testplan report when ready.
reset_test(test_uid, await_results=True)[source]

Reset the report of a single Test instance.

Parameters:
  • test_uid – UID of test to reset.
  • await_results – Whether to block until tests are finished, defaults to True.
Returns:

If await_results is True, returns a testplan report. Otherwise, returns a future which will yield a testplan report when ready.

run()[source]

Setup and run the HTTP handler. Logs connection information to the terminal.

run_all_tests(shallow_report: Optional[Dict[KT, VT]] = None, await_results: bool = True) → Union[testplan.report.testing.base.TestReport, Awaitable[T_co]][source]

Runs all tests.

Parameters:
  • shallow_report – shallow report entry, optional
  • await_results – Whether to block until tests are finished, defaults to True.
Returns:

If await_results is True, returns a testplan report. Otherwise, returns a future which will yield a testplan report when ready.

run_test(test_uid: str, shallow_report: Optional[Dict[KT, VT]] = None, await_results: bool = True) → Union[testplan.report.testing.base.TestReport, Awaitable[T_co]][source]

Run a single Test instance.

Parameters:
  • test_uid – UID of test to run.
  • shallow_report – shallow report entry, optional
  • await_results – Whether to block until the test is finished, defaults to True.
Returns:

If await_results is True, returns a test report. Otherwise, returns a future which will yield a test report when ready.

run_test_case(test_uid: str, suite_uid: str, case_uid: str, shallow_report: Optional[Dict[KT, VT]] = None, await_results: bool = True) → Union[testplan.report.testing.base.TestReport, Awaitable[T_co]][source]

Run a single testcase.

Parameters:
  • test_uid – UID of the test that owns the testcase.
  • suite_uid – UID of the suite that owns the testcase.
  • case_uid – UID of the testcase to run.
  • shallow_report – shallow report entry, optional
  • await_results – Whether to block until the testcase is finished, defaults to True.
Returns:

If await_results is True, returns a testcase report. Otherwise, returns a future which will yield a testcase report when ready.

run_test_case_param(test_uid: str, suite_uid: str, case_uid: str, param_uid: str, shallow_report: Optional[Dict[KT, VT]] = None, await_results: bool = True)[source]

Run a single parametrization of a testcase.

Parameters:
  • test_uid – UID of the test that owns the testcase.
  • suite_uid – UID of the suite that owns the testcase.
  • case_uid – UID of the testcase to run.
  • param_uid – UID of the parametrization to run.
  • shallow_report – shallow report entry, optional
  • await_results – Whether to block until the testcase is finished, defaults to True.
Returns:

If await_results is True, returns a testcase report. Otherwise, returns a future which will yield a testcase report when ready.

run_test_suite(test_uid: str, suite_uid: str, shallow_report: Optional[Dict[KT, VT]] = None, await_results: bool = True) → Union[testplan.report.testing.base.TestReport, Awaitable[T_co]][source]

Run a single test suite.

Parameters:
  • test_uid – UID of the test that owns the suite.
  • suite_uid – UID of the suite to run.
  • shallow_report – shallow report entry, optional
  • await_results – Whether to block until the suite is finished, defaults to True.
Returns:

If await_results is True, returns a testsuite report. Otherwise, returns a future which will yield a testsuite report when ready.

setup()[source]

Set up the task pool and HTTP handler.

start_environment(env_uid)[source]

Start the specified environment.

start_resource(resource)[source]

Start a resource.

start_test_resources(test_uid, await_results=True)[source]

Start all test resources.

Parameters:
  • test_uid – UID of test to start resources for
  • await_results – Whether to block until the test resources have all started, defaults to True.
Returns:

If await_results is True, returns a list of the return values of each resource start operation, otherwise returns a list of async result objects.

start_tests()[source]

Start all tests environments.

stop_environment(env_uid)[source]

Stop the specified environment.

stop_resource(resource)[source]

Stop a resource.

stop_test_resources(test_uid, await_results=True)[source]

Stop all test resources.

Parameters:
  • test_uid – UID of test to stop resources for
  • await_results – Whether to block until the test resources have all stopped, defaults to True.
Returns:

If await_results is True, returns a list of the return values of each resource stop operation, otherwise returns a list of async result objects.

stop_tests(runner_uid=None)[source]

Stop all tests environments.

target

The test runner instance.

teardown()[source]

Close the task pool.

test(test_uid)[source]

Get a test instance with the specified UID.

Parameters:test_uid – UID of test to find.
test_case_report(test_uid, suite_uid, case_uid, serialized=True)[source]

Get a testcase report.

test_report(test_uid, serialized=True, exclude_assertions=False)[source]

Get a test report.

test_resource(test_uid, resource_uid)[source]

Get a resource of a Test instance.

test_resource_operation(test_uid, resource_uid, operation, **kwargs)[source]

Perform an operation on a test environment resource.

test_resource_start(test_uid, resource_uid)[source]

Start a resource of a Test instance.

test_resource_stop(test_uid, resource_uid)[source]

Stop a resource of a Test instance.

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

Bases: testplan.common.config.base.Config

Configuration object for TestRunnerIHandler runnable interactive handler.

classmethod get_options()[source]

Override this classmethod to provide extra config arguments.

testplan.runnable.interactive.http

Http handler for interactive mode.

exception testplan.runnable.interactive.http.OutOfOrderError(msg)[source]

Bases: Exception

class testplan.runnable.interactive.http.TestRunnerHTTPHandler(**options)[source]

Bases: testplan.common.entity.base.Entity

Server that invokes an interactive handler to perform dynamic operations.

Parameters:
  • ihandler (Entity) – Runnable interactive handler instance.
  • host (str) – Host to bind to.
  • port (int) – Port to bind to.

Also inherits all Entity options.

CONFIG

alias of TestRunnerHTTPHandlerConfig

aborting()[source]

Stopping http service.

bind_addr
Returns:Bound host and port of HTTP server, or None if not bound.
Return type:Optional[Tuple[str, int]]
run()[source]

Start serving requests. Will block until the server stops running.

setup()[source]

Generate the flask App and prepare the HTTP server.

Returns:server host and port tuple
Return type:Tuple[str, int]
class testplan.runnable.interactive.http.TestRunnerHTTPHandlerConfig(**options)[source]

Bases: testplan.common.entity.base.EntityConfig

Configuration object for TestRunnerHTTPHandler entity.

classmethod get_options()[source]

Config options for base Entity class.

testplan.runnable.interactive.http.decode_uri_component(func)[source]

Decode URI component before arguments passed to url route handler.

testplan.runnable.interactive.http.generate_interactive_api(ihandler)[source]

Generates the interactive API using Flask.

testplan.runnable.interactive.reloader

Interactive code reloader module.

class testplan.runnable.interactive.reloader.ModuleReloader(extra_deps=None, scheduled_modules=None)[source]

Bases: testplan.common.utils.logger.Loggable

Reloads modules and their dependencies if there was any file modification.

Parameters:
  • extra_deps (Iterable[ModuleType] or Iterable[str]) – Modules to register as extra dependencies to reload, despite not being directly imported by __main__, or paths of these modules.
  • scheduled_modules (Dict[str, str]) – Name of module which has schedule tests, with the module path registered as extra dependencies to reload.
reload(tests, rebuild_dependencies=False)[source]

Reload code and update testsuites in given tests with new code.

Parameters:
  • tests (Iterable[Test]) – Iterable of Tests (e.g. MultiTest).
  • rebuild_dependencies (bool) – Hard re-calculate all file dependencies.

testplan.runnable.interactive.resource_loader

Import classes on runtime.

class testplan.runnable.interactive.resource_loader.ResourceLoader[source]

Bases: object

Load logic.

load(name, kwargs)[source]

Load the registered object for the given name.

Module contents