qcodes/tests/common.py
def error_caused_by(excinfo: 'ExceptionInfo[Any]', cause: str) -> bool:
    """
    Helper function to figure out whether an exception was caused by another
    exception with the message provided.

    Args:
        excinfo: the output of with pytest.raises() as excinfo
        cause: the error message or a substring of it
    """

    exc_repr = excinfo.getrepr()
    assert isinstance(exc_repr, ExceptionChainRepr)
    chain = exc_repr.chain
    # first element of the chain is info about the root exception
    error_location = chain[0][1]
    root_traceback = chain[0][0]
    # the error location is the most reliable data since
    # it only contains the location and the error raised.
    # however there are cases where this is empty
    # in such cases fall back to the traceback
    if error_location is not None:
        return cause in str(error_location)
    else:
        return cause in str(root_traceback)

    Helper function to figure out whether an exception was caused by another
    exception with the message provided.

    Args:
        excinfo: the output of with pytest.raises() as excinfo
        cause: the error message or a substring of it
    
Helper function to figure out whether an exception was caused by another
exception with the message provided.
Helper function to figure out whether an exception was caused by another exception with the message provided .
def error_caused_by(excinfo: 'ExceptionInfo[Any]', cause: str) -> bool:
    exc_repr = excinfo.getrepr()
    assert isinstance(exc_repr, ExceptionChainRepr)
    chain = exc_repr.chain
    error_location = chain[0][1]
    root_traceback = chain[0][0]
    if error_location is not None:
        return cause in str(error_location)
    else:
        return cause in str(root_traceback)
def error_caused_by ( excinfo : 'ExceptionInfo[Any]' , cause : str ) -> bool : exc_repr = excinfo . getrepr ( ) assert isinstance ( exc_repr , ExceptionChainRepr ) chain = exc_repr . chain error_location = chain [ 0 ] [ 1 ] root_traceback = chain [ 0 ] [ 0 ] if error_location is not None : return cause in str ( error_location ) else : return cause in str ( root_traceback )
Helper function to figure out whether an exception was caused by another
exception with the message provided.
Helper function to figure out whether an exception was caused by another exception with the message provided .
"""
    Helper function to figure out whether an exception was caused by another
    exception with the message provided.

    Args:
        excinfo: the output of with pytest.raises() as excinfo
        cause: the error message or a substring of it
    """ # first element of the chain is info about the root exception # the error location is the most reliable data since # it only contains the location and the error raised. # however there are cases where this is empty # in such cases fall back to the traceback
excinfo
'ExceptionInfo[Any]'
the output of with pytest.raises() as excinfo
the output of with pytest . raises () as excinfo
cause
str
the error message or a substring of it
the error message or a substring of it