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)[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]

We abort our test runner instance.

aborting()[source]

Do nothing when aborting.

add_created_environment(env_uid)[source]

Add an environment from the created environment maker instance.

add_environment_resource(env_uid, target_class_name, source_file=None, **kwargs)[source]

Add a resource to existing environment or to environment maker object.

all_tests()[source]

Get all added tests.

all_tests_operation(operation, await_results=True)[source]

Perform an operation in all tests.

create_new_environment(env_uid, env_type=u'local_environment')[source]

Dynamically create an environment maker object.

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_environment_resource(env_uid, target_class_name, source_file=None, **kwargs)[source]
reload_report()[source]

Update report with added/removed testcases

run()[source]

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

run_all_tests(await_results=True)[source]

Run all tests.

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.
run_test(test_uid, await_results=True)[source]

Run a single Test instance.

Parameters:
  • test_uid – UID of test to run.
  • 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, suite_uid, case_uid, await_results=True)[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.
  • 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, suite_uid, case_uid, param_uid, await_results=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.
  • 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, suite_uid, await_results=True)[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.
  • 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
Returns:the target 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.

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

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

Bases: testplan.common.utils.logger.Loggable

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

Parameters:extra_deps (Iterable[ModuleType]) – Modules to register as extra dependencies to reload, despite not being directly imported by __main__.
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