scenario.testerrors module

Test errors.

exception TestError(message, location=None)

Bases: Exception

Base test error object.

Stores information about an error that occurred during the test.

Declared as an exception so that it can be propagated as is.

__init__(message, location=None)
Parameters:
  • message – Error message.

  • location – Error location.

message

Error message.

location

Error location.

__str__()

Short representation of the error.

__repr__()

Programmatic representation of the error.

iserror()

Tells whether this error object is actually an error.

Returns:

True for a real error, False for a simple warning (see iswarning()) or when the error should be ignored (see isignored()).

iswarning()

Tells whether this error object is just a warning.

Returns:

True for a simple warning, False for a real error (see iserror()) or when the error should be ignored (see isignored()).

isignored()

Tells whether this error object should be ignored.

Returns:

True when the error should be ignored, False for a real error (see iserror()) or a warning (see iswarning()).

logerror(logger, level=40, indent='')

Logs the error info.

Parameters:
  • logger – Logger to use for logging.

  • level – Log level.

  • indent – Indentation to use.

tojson()

Converts the TestError instance into a JSON dictionary.

Returns:

JSON dictionary.

static fromjson(json_data)

Builds a TestError instance from its JSON representation.

Parameters:

json_data – JSON dictionary.

Returns:

New TestError instance.

exception ExceptionError(exception=None)

Bases: TestError

Test error related to an exception.

__init__(exception=None)
Parameters:

exception – Root cause exception, if available.

exception

The root cause exception, if any.

exception_type

Type of the exception, if any.

__str__()

Short representation of the exception error.

Exception type + message.

logerror(logger, level=40, indent='')

TestError.logerror() override in order to log the exception traceback, if an exception is stored.

Defaults to TestError.logerror() if no exception.

tojson()

Converts the TestError instance into a JSON dictionary.

Returns:

JSON dictionary.

static fromjson(json_data)

Builds a ExceptionError instance from its JSON representation.

Parameters:

json_data – JSON dictionary.

Returns:

New ExceptionError instance.