MCPcopy
hub / github.com/psf/requests / test_post_with_custom_mapping

Method test_post_with_custom_mapping

tests/test_requests.py:899–922  ·  view source on GitHub ↗
(self, httpbin)

Source from the content-addressed store, hash-verified

897 requests.post(url, files=["bad file data"])
898
899 def test_post_with_custom_mapping(self, httpbin):
900 class CustomMapping(MutableMapping):
901 def __init__(self, *args, **kwargs):
902 self.data = dict(*args, **kwargs)
903
904 def __delitem__(self, key):
905 del self.data[key]
906
907 def __getitem__(self, key):
908 return self.data[key]
909
910 def __setitem__(self, key, value):
911 self.data[key] = value
912
913 def __iter__(self):
914 return iter(self.data)
915
916 def __len__(self):
917 return len(self.data)
918
919 data = CustomMapping({"some": "data"})
920 url = httpbin("post")
921 found_json = requests.post(url, data=data).json().get("form")
922 assert found_json == {"some": "data"}
923
924 def test_conflicting_post_params(self, httpbin):
925 url = httpbin("post")

Callers

nothing calls this directly

Calls 5

CustomMappingClass · 0.85
httpbinFunction · 0.85
jsonMethod · 0.80
postMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected