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:
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'¶
-
classmethod
-
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
class: avocado.core.teststatus.STATUSES
Parameters: Returns: finished message
Return type:
-
message_status
= 'finished'¶
-
classmethod
-
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¶
-
classmethod
-
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¶
-
classmethod
-
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
Parameters: - queue (multiprocessing.SimpleQueue) – queue for the runner messages
- message_type (string) – type of the log
-
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.
-
message_only_formatter
¶ 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
Parameters: - queue (multiprocessing.SimpleQueue) – queue for the runner messages
- message_type (string) – type of the log
-
flush
()¶
-
write
(buf)¶
-
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.
Parameters: - config (dict) – avocado configuration
- queue (multiprocessing.SimpleQueue) – queue for the runner messages
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