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:
Field
Return 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:
Field
Serialization 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:
Field
Serialize exceptions type and message.
- class testplan.common.serialization.fields.FormattedValue(value, display)[source]
Bases:
Serializable
Save a formatted value in WebUI
- class testplan.common.serialization.fields.GenericNested(schema_context, type_field='type', default=<marshmallow.missing>, **kwargs)[source]
Bases:
Field
Marshmallow 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
Return schema mapping in <CLASS_NAME>: <SCHEMA_OBJECT> format.
- class testplan.common.serialization.fields.LocalDateTime(format: str | None = None, **kwargs)[source]
Bases:
DateTime
A 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, title=None, new_window=True, inner=False)[source]
Bases:
Serializable
Save 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:
Field
Uses 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:
Field
Dictionary 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:
Field
Serialization 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:
Field
Serialization logic for SliceComparison
- class testplan.common.serialization.fields.UTCDateTime(format: str | None = None, **kwargs)[source]
Bases:
DateTime
A 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:
Field
Field 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:
Field
Custom field for lxml.etree.Element serialization.
- testplan.common.serialization.fields.native_or_pformat(value)[source]
Generic serialization compatible value formatter.
testplan.common.serialization.schemas module
- class testplan.common.serialization.schemas.SchemaRegistry[source]
Bases:
Registry
Registry 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:
Schema
Base class that can be used for defining tree node schemas, compatible with load_tree_data.
- classmethod get_source_class()[source]
Wrapper around class level attribute to support inheritance.
- 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:
Exception
general deserialization error
- class testplan.common.serialization.SelectiveSerializable[source]
Bases:
ABC
- abstract property serializable_attrs: Iterable[str]
Attributes to be included in serialization.