verification_functions

Common functions for verifying values and printing out errors and failures.

raise_error

raise_error(unique_identifier: str, message: str, *, condense_printout: bool = True) -> None

Raise an AssertionError with the provided message indicating there was an error.

Parameters:
  • unique_identifier (str) –

    A unique identifier to add to the AssertionError, e.g. the device name.

  • message (str) –

    The message to add to the AssertionError.

  • condense_printout (bool, default: True ) –

    A boolean indicating if the printout should be condensed.

Raises:

raise_failure

raise_failure(unique_identifier: str, message: str, *, condense_printout: bool = True) -> None

Raise an AssertionError with the provided message indicating there was a failure.

Parameters:
  • unique_identifier (str) –

    A unique identifier to add to the AssertionError, e.g. the device name.

  • message (str) –

    The message to add to the AssertionError.

  • condense_printout (bool, default: True ) –

    A boolean indicating if the printout should be condensed.

Raises:

verify_values

verify_values(
    unique_identifier: str,
    expected_value: str | float,
    actual_value: str | float,
    *,
    tolerance: float = 0,
    percentage: bool = False,
    custom_message_prefix: str = "",
    log_error: bool = False,
    expect_fail: bool = False,
    use_regex_match: bool = False,
    condense_printout: bool = True
) -> bool

Compare and verify actual value with expected value.

Parameters:
  • unique_identifier (str) –

    A unique identifier to add to the AssertionError, e.g. the device name.

  • expected_value (str | float) –

    The expected value.

  • actual_value (str | float) –

    The actual value.

  • tolerance (float, default: 0 ) –

    The acceptable difference between two floating point values, e.g. 0.0005

  • percentage (bool, default: False ) –

    A boolean indicating what kind of tolerance check to perform. False means absolute tolerance: +/- tolerance. True means percent tolerance: +/- (tolerance / 100) * value.

  • custom_message_prefix (str, default: '' ) –

    A custom message to be prepended to the failure message.

  • log_error (bool, default: False ) –

    Indicate if an error should be logged instead of a failure

  • expect_fail (bool, default: False ) –

    Indicate if a failure is expected and should be treated as a pass

  • use_regex_match (bool, default: False ) –

    A boolean indicating if the strings should be compared using regular expressions.

  • condense_printout (bool, default: True ) –

    A boolean indicating if the printout should be condensed.

Returns:
  • bool

    Boolean indicating whether the check passed or failed.