testapp

Test bottle app without running bottle server

こ雲淡風輕ζ 提交于 2019-12-23 03:00:13
问题 I am following Recipes of bottle framework. When I try below code #filename: mywebapp.py from bottle import Bottle, run, request app = Bottle() @app.get('/hello') def hello(): return "Hello " + request.get_header('name') if __name__ == '__main__': run(app, host='localhost', port=80) Function testcase with TestApp #filename: test_mywebapp.py from webtest import TestApp import mywebapp def test_functional_hello_world(): app = TestApp(mywebapp.app) assert app.get('/hello').status_code == 200