'How to mock an object that you iterate on then call his attributes?

I am trying to test a function using sqlalchemy. In the code I have this :

    for column in inspect(table).c:
        column_details = [column.name, column.type.python_type, column.nullable]

(inspect is a method from sqlalchemy)

I managed to patch inspect but how am I supposed to set it in a way I can iterate on, then call his functions ? If I do this I have an AttributeError :

@patch("check_inputs.inspect")
def test_get_table_columns_details_empty(inspect):

    inspcet = []

    inspect.return_value.name = PropertyMock(return_value="id")


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source