

def test_error_writer(self):
    response = self.request('/unknown-error')
    self.assertEqual(response.headers['Content-Type'], 'application/json; charset=UTF-8')
    self.assertTrue((b'Exception: Test 1' in response.body))
    response = self.request('/api-error')
    json = tornado.escape.json_decode(response.body)
    self.assertEqual(json.code, 401)
    self.assertEqual(response.headers['Content-Type'], 'application/json; charset=UTF-8')
    self.assertEqual(json['code'], 401)
    self.assertEqual(json['error'], 'Test 2')
    self.assertTrue(('trace' in json))

dataset/ETHPy150Open dailymuse/oz/oz/json_api/tests/test_middleware.py ApiMiddlewareTestCase.test_error_writer/VarMisuse@72/110 `response`->`json`