testplan.common.config package

Submodules

testplan.common.config.base module

Module containing configuration objects and utilities.

class testplan.common.config.base.Config(**options)[source]

Bases: object

Base class for creating a configuration object with a schema that can define default values and support inheritance. Configurations can have a parent-child relationship so that options not defined in the child, can be retrieved from parent. Supports composition of multiple config options via multiple inheritance.

classmethod build_schema()[source]

Build a validation schema using the config options defined in this class and its parent classes.

denormalize()[source]

Create new config object that inherits all explicit attributes from its parents as well.

get_local(name, default=None)[source]

Returns a local config setting (not from container)

classmethod get_options()[source]

Override this classmethod to provide extra config arguments.

ignore_extra_keys = False
parent

Returns the parent configuration.

set_local(name, value)[source]

set without any check

testplan.common.config.base.ConfigOption(key: str, default=<object object>) → schema.Optional[source]

Wrapper around Optional, subclassing is not an option as Schema library does internal type checks as type(obj) is Optional.

User can specify a default value when defining a config option. If not specified, it takes ABSENT as default value.

When accessing a config option of an entity, we will first look in the config object of the entity itself (this also includes the options that are inherited from its parent). If a particular option is not defined or defined but only has an ABSENT value, we will recursively look in the entity’s container until we find it. Typical containing relationships are like TestRunner contains Pool, TestRunner contains MultiTest, Pool contains Worker etc.

Thus a config option takes one of these values in descending precedence:
user specified -> a non-ABSENT default -> container’s value

Exception will be throw if we cannot find a valid value for a config option after we exhaust the entity’s containers.

class testplan.common.config.base.Configurable[source]

Bases: testplan.common.utils.logger.Loggable

To be inherited by objects that accept configuration.

classmethod with_config(**config)[source]

Returns a tuple of class and configuration.

class testplan.common.config.base.UNSET_T[source]

Bases: object

testplan.common.config.base.update_options(target, source)[source]

Given a target and source dictionary, update the target dict in place using the keys in source dict, if the keys do not exist in target. This is not simple dict update as in we can have target and source dicts like this: >>> target = {ConfigOption(‘foo’): int} >>> source = {‘foo’: int} For the example above, target will not be updated as the ‘names’ of the keys are the same, even if they don’t have the same hash.

testplan.common.config.base.validate_func(*arg_names)[source]

Validate given function signature.

Module contents

class testplan.common.config.UNSET_T[source]

Bases: object

class testplan.common.config.Config(**options)[source]

Bases: object

Base class for creating a configuration object with a schema that can define default values and support inheritance. Configurations can have a parent-child relationship so that options not defined in the child, can be retrieved from parent. Supports composition of multiple config options via multiple inheritance.

classmethod build_schema()[source]

Build a validation schema using the config options defined in this class and its parent classes.

denormalize()[source]

Create new config object that inherits all explicit attributes from its parents as well.

get_local(name, default=None)[source]

Returns a local config setting (not from container)

classmethod get_options()[source]

Override this classmethod to provide extra config arguments.

ignore_extra_keys = False
parent

Returns the parent configuration.

set_local(name, value)[source]

set without any check

testplan.common.config.ConfigOption(key: str, default=<object object>) → schema.Optional[source]

Wrapper around Optional, subclassing is not an option as Schema library does internal type checks as type(obj) is Optional.

User can specify a default value when defining a config option. If not specified, it takes ABSENT as default value.

When accessing a config option of an entity, we will first look in the config object of the entity itself (this also includes the options that are inherited from its parent). If a particular option is not defined or defined but only has an ABSENT value, we will recursively look in the entity’s container until we find it. Typical containing relationships are like TestRunner contains Pool, TestRunner contains MultiTest, Pool contains Worker etc.

Thus a config option takes one of these values in descending precedence:
user specified -> a non-ABSENT default -> container’s value

Exception will be throw if we cannot find a valid value for a config option after we exhaust the entity’s containers.

class testplan.common.config.Configurable[source]

Bases: testplan.common.utils.logger.Loggable

To be inherited by objects that accept configuration.

classmethod with_config(**config)[source]

Returns a tuple of class and configuration.

testplan.common.config.validate_func(*arg_names)[source]

Validate given function signature.