the hardcoded value it is checking for threw me off took me a second to figure out  instead  extend fakehttpconnection  override request and always return your malformed body  then put your test method into a new unittest testcase that sets up self middleware http client class as your extended fakehttpconnection class 