testplan.common.serialization package
Submodules
testplan.common.serialization.fields module
Custom marshmallow fields.
- class testplan.common.serialization.fields.ClassName(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldReturn the class name of the obj.
- class testplan.common.serialization.fields.ColumnContainComparisonField(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldSerialization logic for ColumnContainComparison
- class testplan.common.serialization.fields.DictMatch(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
Field
- class testplan.common.serialization.fields.ExceptionField(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldSerialize exceptions type and message.
- class testplan.common.serialization.fields.FormattedValue(value: Any, display: str)[source]
Bases:
SerializableSave a formatted value in WebUI
- class testplan.common.serialization.fields.GenericNested(schema_context: ~typing.Dict[~typing.Any, ~typing.Any], type_field: str = 'type', default: ~typing.Any = <marshmallow.missing>, **kwargs: ~typing.Any)[source]
Bases:
FieldMarshmallow does not support multiple schemas for a single Nested field.
There is a project (marshmallow-oneofschema) that has similar functionality but it doesn’t support self-referencing schemas, which is needed for serializing tree structures.
This field should be used along with ClassNameField to return the type (class name) of the objects, so it can choose the correct schema during deserialization.
- property schemas: Dict[str, Schema]
Return schema mapping in <CLASS_NAME>: <SCHEMA_OBJECT> format.
- class testplan.common.serialization.fields.LocalDateTime(format: str | None = None, **kwargs)[source]
Bases:
DateTimeA formatted datetime string that represents machine time. Naive datetime will be thought as in local timezone. Example: 2014-12-22T11:12:58.019077+08:00
Note: Since Python 3.6 datetime.datetime.astimezone method can be called on naive instances that are presumed to represent system local time.
- class testplan.common.serialization.fields.LogLink(link: str, title: str | None = None, new_window: bool = True, inner: bool = False)[source]
Bases:
SerializableSave an HTML link in WebUI
- class testplan.common.serialization.fields.NativeOrPretty(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldUses serialization compatible native values or pretty formatted str representation.
- class testplan.common.serialization.fields.NativeOrPrettyDict(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldDictionary serialization with native or pretty formatted values. Keys should be JSON serializable (str type), should be used for flat dicts only.
- class testplan.common.serialization.fields.RowComparisonField(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldSerialization logic for RowComparison
- class testplan.common.serialization.fields.SliceComparisonField(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldSerialization logic for SliceComparison
- class testplan.common.serialization.fields.UTCDateTime(format: str | None = None, **kwargs)[source]
Bases:
DateTimeA formatted datetime string that represents UTC time. Naive datetime will be thought as in UTC timezone. Example: 2014-12-22T03:12:58.019077+00:00 (always ends with ‘+00:00’)
- class testplan.common.serialization.fields.Unicode(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldField that tries to convert value into a unicode
object with the given codecs. Marshmallow internally decodes to utf-8 encoding, however it fails on Python 2 for str values like
@té§tþlåñ.So we have this field with explicit codecs instead.
- codecs = ['utf-8', 'latin-1']
- class testplan.common.serialization.fields.XMLElementField(*, load_default: ~typing.Any = <marshmallow.missing>, missing: ~typing.Any = <marshmallow.missing>, dump_default: ~typing.Any = <marshmallow.missing>, default: ~typing.Any = <marshmallow.missing>, data_key: str | None = None, attribute: str | None = None, validate: ~typing.Callable[[~typing.Any], ~typing.Any] | ~typing.Iterable[~typing.Callable[[~typing.Any], ~typing.Any]] | None = None, required: bool = False, allow_none: bool | None = None, load_only: bool = False, dump_only: bool = False, error_messages: dict[str, str] | None = None, metadata: ~typing.Mapping[str, ~typing.Any] | None = None, **additional_metadata)[source]
Bases:
FieldCustom field for lxml.etree.Element serialization.
- testplan.common.serialization.fields.native_or_pformat(value: Any) Any[source]
Generic serialization compatible value formatter.
testplan.common.serialization.schemas module
- class testplan.common.serialization.schemas.SchemaRegistry[source]
Bases:
RegistryRegistry class to be used with Marshmallow schemas, provides serialize method that calls dump on the underlying schema mapping.
- class testplan.common.serialization.schemas.TreeNodeSchema(*, only: Sequence[str] | AbstractSet[str] | None = None, exclude: Sequence[str] | AbstractSet[str] = (), many: bool | None = None, context: dict | None = None, load_only: Sequence[str] | AbstractSet[str] = (), dump_only: Sequence[str] | AbstractSet[str] = (), partial: bool | Sequence[str] | AbstractSet[str] | None = None, unknown: str | None = None)[source]
Bases:
SchemaBase class that can be used for defining tree node schemas, compatible with load_tree_data.
- dump_fields: dict[str, Field]
- exclude: set[Any] | MutableSet[Any]
- fields: dict[str, Field]
Dictionary mapping field_names ->
Fieldobjects
- classmethod get_source_class()[source]
Wrapper around class level attribute to support inheritance.
- load_fields: dict[str, Field]
- opts: Any = <marshmallow.schema.SchemaOpts object>
- source_class = None
- testplan.common.serialization.schemas.load_tree_data(data, node_schema, leaf_schema, nodes_field='entries', nodes_attr_name='entries', type_field='type')[source]
marshmallow does not support tree serialization with different node types, so we rely on this recursive function for traversing tree data and instantiate node objects with the given schemas.
Module contents
- exception testplan.common.serialization.DeserializationError[source]
Bases:
Exceptiongeneral deserialization error
- class testplan.common.serialization.SelectiveSerializable[source]
Bases:
ABC- abstract property serializable_attrs: Iterable[str]
Attributes to be included in serialization.