我碰到下面的错误时,我想在我的代码来测试一个404 HTTP错误路径:内容长度错误
AssertionError: Content-Length is different from actual app_iter length (512!=60)
我已经创建了一个触发该行为最少的样品:
import unittest
import endpoints
from protorpc import remote
from protorpc.message_types import VoidMessage
import webtest
@endpoints.api(name='test', version='v1')
class HelloWorld(remote.Service):
@endpoints.method(VoidMessage, VoidMessage,
path='test_path', http_method='POST',
name='test_name')
def test(self, request):
raise endpoints.NotFoundException("Not found")
class AppTest(unittest.TestCase):
def setUp(self):
app = endpoints.api_server([HelloWorld])
self.testapp = webtest.TestApp(app)
# Test the handler.
def testHelloWorldHandler(self):
response = self.testapp.post('/_ah/spi/HelloWorld.test', extra_environ={
'SERVER_SOFTWARE': 'Development/X', 'CONTENT_TYPE': 'application/json'})
那么我做错了什么?
那是完整的错误?我猜不是... – Veedrac
我也是 - 当你在服务器上引发一个端点异常时它会发生。我发现这个http://trac.turbogears.org/ticket/2454,但仍然没有修复它 - 我会让你知道我的时间:) –