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¶
- class avocado.core.utils.loader.TestError(*args, **kwargs)¶
Bases:
Test
Generic test error.
Initializes the test.
- Parameters
methodName – Name of the main method to run. For the sake of compatibility with the original unittest class, you should not set this.
name (
avocado.core.test.TestID
) – Pretty name of the test name. For normal tests, written with the avocado API, this should not be set. This is reserved for internal Avocado use, such as when running random executables as tests.base_logdir – Directory where test logs should go. If None provided a temporary directory will be created.
config (dict) – the job configuration, usually set by command line options and argument parsing
- test()¶
- 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.
- 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)¶
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'¶
- 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
- message_status = None¶
- class avocado.core.utils.messages.GenericRunningMessage¶
Bases:
GenericMessage
- classmethod get(msg, **kwargs)¶
Creates running message with all necessary information.
- 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
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.
- 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
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:
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
avocado.core.utils.version module¶
- avocado.core.utils.version.get_avocado_git_version()¶