def METHOD_NAME(self, expr, flags, bin, expected):
    """
    Test expression write operation expecting failure.
    """
    with pytest.raises(expected):
        ops = [expressions.expression_write(bin, expr, flags)]
        self.as_connection.operate(self.key, ops)