httpretty

Python requests.post fails in 421

Python requests.post fails in 421 Question: I have the following code in the implementation (uses requests lib): def call_service(product_ids: Set[str]) response = requests.post( json={"product_ids": product_ids}, url="http://whatever.com", ) if response.status_code == 421: raise MisRedirectedRequest() I’m using HTTPretty’s to simulate this in a test: @httpretty.activate def test_http_status_code_421(): httpretty.register_uri( method=httpretty.POST, uri="http://whatever.com", body="{}", status=421, ) with pytest.raises(MisRedirectedRequest): call_service({"123", "543"}) …

Total answers: 1