testplan.common.report package¶
Submodules¶
testplan.common.report.base module¶
Base classes for building a report tree.
The idea behind this module is that we may have parallel runners for a testplan, each of which would generate a partial report.
Later on these reports would be merged together to build the final report as the testplan result.
-
class
testplan.common.report.base.
ExceptionLogger
(*exception_classes, **kwargs)[source]¶ Bases:
object
A context manager used for suppressing & logging an exception.
-
exception
testplan.common.report.base.
MergeError
[source]¶ Bases:
Exception
Raised when a merge operation fails.
-
class
testplan.common.report.base.
Report
(name: str, description: Optional[str] = None, definition_name: Optional[str] = None, uid: Optional[str] = None, entries: Optional[list] = None, parent_uids: Optional[List[str]] = None)[source]¶ Bases:
object
Base report class, support exception suppression & logging via report.logged_exceptions. Stores arbitrary objects in entries attribute.
-
exception_logger
¶ alias of
ExceptionLogger
-
filter
(*functions, **kwargs)[source]¶ Filtering report’s entries in place using the given functions. If any of the functions return
True
for a given entry, it will be kept.
-
flattened_entries
(depth)[source]¶ Utility function that is used by TestGroupReport.flatten.
This method should be overridden if entries have a custom hierarchy instead of a simple list.
-
hash
¶ Return a hash of all entries in this report.
-
logged_exceptions
(*exception_classes, **kwargs)[source]¶ Wrapper around ExceptionRecorder, passing report arg implicitly.
Basic usage:
with report.logged_exceptions(TypeError, ValueError): raise some errors here ...
-
merge
(report, strict=True)[source]¶ Child classes can override this, just make sure merge operation is idempotent, so that merging the same report onto self multiple times does not create extra data.
Parameters: - report (
Report
) – Report that contains logs to merge. - strict (
bool
) – Flag for enabling / disabling strict merge ops.
- report (
-
-
class
testplan.common.report.base.
ReportGroup
(name: str, events: Dict[KT, VT] = None, host: Optional[str] = None, **kwargs)[source]¶ Bases:
testplan.common.report.base.Report
A report class that contains other Reports or ReportGroups in entries. Allows O(1) child report lookup via get_by_uid method.
-
add_event
(event_executor: testplan.monitor.event.EventRecorder, event_id: Optional[str] = None) → str[source]¶
-
build_index
(recursive=False)[source]¶ Build (refresh) indexes for this report and optionally for each child report.
This should be called explicitly if self.entries is changed.
Parameters: recursive ( bool
) – Flag for triggering index build on children.
-
entry_uids
¶ Return the UIDs of all entries in this report group.
-
events
¶
-
flatten
(depths=False)[source]¶ Depth-first traverse the report tree starting on the leftmost node (smallest index), return a list of (depth, obj) tuples or a list of reports depending on depths flag.
Parameters: depths – Flag for enabling/disabling depth data in result. Returns: List of reports or list of (depth, report) tuples.
-
flattened_logs
¶ Return a flattened list of the logs from each Report.
-
get_by_uid
(uid)[source]¶ Get child report via uid lookup.
Parameters: uid ( hashable
) – uid for the child report.
-
get_by_uids
(uids)[source]¶ Get child report via a series of uid lookup.
Parameters: uids ( list
ofhashable
) – A uid for the child report.
-
merge_children
(report, strict=True)[source]¶ Merge each children separately, raising
MergeError
if uid does not match.
-
reset_uid
(uid=None)[source]¶ Reset uid of test report and all of its children, it can be useful when need to generate global unique id for each report entry before saving, by default strings in standard UUID format will be applied.
-
testplan.common.report.log module¶
We’d like to use python’s logging interface when we log messages through Report objects. The most lightweight way to do it is to use a logging.LoggingAdapter which is a thin wrapper around a logging.Logger.
We can then use a global mapping and a custom handler to append log messages to the report object’s logs list.
testplan.common.report.schemas module¶
Base schemas for report serialization.
-
class
testplan.common.report.schemas.
ReportLogSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
marshmallow.schema.Schema
Schema for log record data created by report stdout.
-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
-
class
testplan.common.report.schemas.
ReportSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
testplan.common.serialization.schemas.TreeNodeSchema
Schema for
base.Report
.-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
source_class
¶ alias of
testplan.common.report.base.Report
-
-
class
testplan.common.report.schemas.
ReportGroupSchema
(*, only: types.StrSequenceOrSet | None = None, exclude: types.StrSequenceOrSet = (), many: bool = False, context: dict | None = None, load_only: types.StrSequenceOrSet = (), dump_only: types.StrSequenceOrSet = (), partial: bool | types.StrSequenceOrSet = False, unknown: str | None = None)[source]¶ Bases:
testplan.common.report.schemas.ReportSchema
Schema for
base.ReportGroup
.-
opts
= <marshmallow.schema.SchemaOpts object>¶
-
source_class
¶
-