Feedback Writers¶
Implements the feedback writers providing the output to the user.
- class Writer¶
Base writer interface.
Handles the opening and closing of resouces (files, file descriptors, streams, and so on).
Also defines how the output is provided to the user. Current implementations are:
- Parameters:
is_atv2 –
Trueif the run environment is AutoTest V2.
Methods
Cleans up the resources used by the writer.
Defines how the feedback is provided to the user.
- abstract finalize()¶
Cleans up the resources used by the writer.
Assertercalls this method when exiting to make sure no open handles are left.- Return type:
None
- abstract write(cond, maker, positive_feedback, negative_feedback)¶
Defines how the feedback is provided to the user.
- Parameters:
cond (
bool) – The condition that must be satisfied for the assertion to pass. If resolved toTrue, the positive feedback (or its default) is output, otherwise the negative feedback (or its default) is output.maker (
Callable[[Union[str,NoFeedback,None],FeedbackType],Union[str,NoFeedback]]) – The feedback maker function.positive_feedback (
Union[str,NoFeedback,None]) – The positive feedback override.negative_feedback (
Union[str,NoFeedback,None]) – The negative feedback override.
- Return type:
None
- class StructuredOutputWriter¶
Writer that uses structured output to report feedback.
It also rises a
FeedbackAssertionErrorwithout message in case of failures.If the code is running on ATv2, or the environment variable
CG_FEEDBACK_HELPERS_TRUNCATEis set, it uses thecg truncatecommand under the hood.
- class ExceptionsWriter¶
Writer that uses exceptions to report negative feedback.
Positive feedback is printed to standard output.
This can also be used as a debug writer as the text is clearly written in the output, instead of formatted for structured output feedback message format.
- class FeedbackAssertionError¶
Exception raised when an assertion fails.
Inherits from
SystemExitto make the execution exit gracefully.NO_FEEDBACKpasses1to the constructor ofSystemExit.- Parameters:
feedback (
Union[str,NoFeedback]) – The feedback message to display the user.