@contextmanager
def patch_read_csv(url_map, module=pd, strict=False):
 read_csv = pd.read_csv
 def patched_read_csv(filepath_or_buffer, *args, **kwargs):
  if (filepath_or_buffer in url_map):
   return read_csv(url_map[filepath_or_buffer], *args, **kwargs)
  elif (not strict):
   return read_csv(filepath_or_buffer, *args, **kwargs)
  else:
   raise AssertionError(('attempted to call read_csv on  %r which not in the url map' % filepath_or_buffer))
 with patch.object(module, 'read_csv', patched_read_csv):
  (yield)

@ contextmanager def patch_read_csv ( url_map , module = pd , strict = False ) : read_csv = pd . read_csv def patched_read_csv ( filepath_or_buffer , * args , ** kwargs ) : if ( filepath_or_buffer in url_map ) : return read_csv ( url_map [ filepath_or_buffer ] , * args , ** kwargs ) elif ( not strict ) : return read_csv ( filepath_or_buffer , * args , ** kwargs ) else : raise AssertionError ( ( 'attempted to call read_csv on  %r which not in the url map' % filepath_or_buffer ) ) with patch . object ( module , 'read_csv' , patched_read_csv ) : ( yield )
patch pandas .