调试和测试之单元测试

单测例子

test/handlers/test_{app_name}-{handler_name}.py

from handlers.x import hello
from xlib import httpgateway

def test_hello():
    # 生成 req
    reqid="test_hello"
    ip = "127.0.0.1"
    wsgienv = {}
    req = httpgateway.Request(reqid, wsgienv, ip)

    # OK
    assert hello(req, "test_info") == ("OK", {'str_info': 'test_info'}, [('api_demo', '1.0.1')])

Last updated