unit testing - Substituting a variable in a test (using mock? or otherwise) in Python -


i have function puts sql dataframe. using pandas such code looks this:

def get_all_sql_data(connection):      code = 'select * table1'     data = pd.read_sql(code, connection)     ...     ...     ...     return value 

however, since not take data our databases in test code, looking substitute data data csv file in test.

i know how using mocks if 'data' explicit argument of function. there way me replace variable within function data use? if not, there better workaround testing problem?


Comments