avocado.core.utils package

Submodules

avocado.core.utils.eggenv module

avocado.core.utils.eggenv.get_python_path_env_if_egg()

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

avocado.core.utils.loader.load_test(test_factory)

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: 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: 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 (values for the statuses defined in :class: avocado.core.teststatus.STATUSES) – test result

  • 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

Returns:

finished message

Return type:

dict

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: 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: GenericRunningMessage

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

Bases: GenericRunningMessage

Creates output message with all necessary information.

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

Bases: Handler

Runner logger which will put every log to the runner queue

Parameters:
emit(record)

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 message_only_formatter

Property that initiates a logging.Formatter lazily

class avocado.core.utils.messages.RunningMessage

Bases: GenericMessage

Creates running message without any additional info.

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

Bases: GenericMessage

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

Bases: GenericRunningMessage

Creates stderr message with all necessary information.

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

Bases: 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

Parameters:
flush()
write(buf)
class avocado.core.utils.messages.WhiteboardMessage

Bases: 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.

Parameters:

avocado.core.utils.path module

avocado.core.utils.path.prepend_base_path(value)
avocado.core.utils.path.system_wide_or_base_path(file_path)

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

avocado.core.utils.version.get_avocado_git_version()

Module contents