avocado.core.utils package


avocado.core.utils.eggenv module


Returns an environment mapping with an extra PYTHONPATH for the egg or None

When running Avocado Python modules, the interpreter on the new process needs to know where Avocado can be found. This is usually handled by the Avocado installation being available to the standard Python installation, but if Avocado is running from an uninstalled egg, it needs extra help.

Returns:environment mapping with an extra PYTHONPATH for the egg or None
Return type:os.environ mapping or None

avocado.core.utils.loader module


Load test from the test factory.

Parameters:test_factory (tuple) – a pair of test class and parameters.
Returns:an instance of avocado.core.test.Test.

avocado.core.utils.messages module

class avocado.core.utils.messages.FileMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

Creates file message with all necessary information.

classmethod get(msg, path)

Creates running message with all necessary information.

Parameters:msg (str) – log of running message
Returns:running message
Return type:dict
message_type = 'file'
class avocado.core.utils.messages.FinishedMessage

Bases: avocado.core.utils.messages.GenericMessage

classmethod get(result, fail_reason=None, returncode=None, class_name=None, fail_class=None, traceback=None, **kwargs)

Creates finished message with all necessary information.

Parameters:result – test result
:type result values for the statuses defined in
  • fail_reason (str) – parameter for brief specification, of the failed result.
  • returncode – exit status of runner
  • class_name (str) – class name of the test
  • fail_class (str) – Exception class of the failure
  • traceback (str) – Traceback of the exception

finished message

Return type:


message_status = 'finished'
class avocado.core.utils.messages.GenericMessage

Bases: object

classmethod get(**kwargs)

Creates message base on it’s type with all necessary information.

Returns:message dict which can be send to avocado server
Return type:dict
message_status = None
class avocado.core.utils.messages.GenericRunningMessage

Bases: avocado.core.utils.messages.GenericMessage

classmethod get(msg, **kwargs)

Creates running message with all necessary information.

Parameters:msg (str) – log of running message
Returns:running message
Return type:dict
message_status = 'running'
message_type = None
class avocado.core.utils.messages.LogMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

message_type = 'log'
class avocado.core.utils.messages.OutputMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

Creates output message with all necessary information.

message_type = 'output'
class avocado.core.utils.messages.RunnerLogHandler(queue, message_type, kwargs=None)

Bases: logging.Handler

Runner logger which will put every log to the runner queue


Do whatever it takes to actually log the specified logging record.

This version is intended to be implemented by subclasses and so raises a NotImplementedError.


Property that initiates a logging.Formatter lazily

class avocado.core.utils.messages.RunningMessage

Bases: avocado.core.utils.messages.GenericMessage

Creates running message without any additional info.

message_status = 'running'
class avocado.core.utils.messages.StartedMessage

Bases: avocado.core.utils.messages.GenericMessage

message_status = 'started'
class avocado.core.utils.messages.StderrMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

Creates stderr message with all necessary information.

message_type = 'stderr'
class avocado.core.utils.messages.StdoutMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

Creates stdout message with all necessary information.

message_type = 'stdout'
class avocado.core.utils.messages.StreamToQueue(queue, message_type)

Bases: object

Runner Stream which will transfer data to the runner queue

class avocado.core.utils.messages.WhiteboardMessage

Bases: avocado.core.utils.messages.GenericRunningMessage

Creates whiteboard message with all necessary information.

message_type = 'whiteboard'
avocado.core.utils.messages.start_logging(config, queue)

Helper method for connecting the avocado logging with avocado messages.

It will add the logHandlers to the :class: avocado.core.output loggers, which will convert the logs to the avocado messages and sent them to processing queue.


avocado.core.utils.path module


Returns either a system wide path, or one relative to the base.

If “etc/avocado/avocado.conf” is given as input, it checks for the existence of “/etc/avocado/avocado.conf”. If that path does not exist, then a path starting with the avocado’s Python’s distribution is returned. In that case it’d return something like “/usr/lib/python3.9/site-packages/avocado/etc/avocado/avocado.conf”.

Parameters:file_path (str) – a filesystem path that can either be absolute, or relative. If relative, the absolute equivalent (that is, by prefixing the filesystem root location) is checked for existence. If it does not exist, a path relative to the Python’s distribution base path is returned.
Return type:str

avocado.core.utils.version module


Module contents