You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is because 2.0 becomes the value of data, which must be iterable in requests, but can be anything in _fake_send, Putting in a type check for data would at least fix this (perhaps most common variant) even if it's not perfect
The text was updated successfully, but these errors were encountered:
import requests
def custom_post(url, data=None, **kwargs):
# Check if data is provided and if it's iterable (e.g., a list or dictionary)
if data is not None and not isinstance(data, (list, dict)):
raise TypeError("data must be an iterable (e.g., list or dictionary)")
return requests.post(url, data=data, **kwargs)
I ran into this issue today, where everything worked in tests but failed when not mocked.
Compare to
This is because 2.0 becomes the value of
data
, which must be iterable inrequests
, but can be anything in_fake_send
, Putting in a type check fordata
would at least fix this (perhaps most common variant) even if it's not perfectThe text was updated successfully, but these errors were encountered: