mercredi 22 janvier 2020

How to test web app with pytest whether it returns json?

I have a sanic web app, which returns json file hello world (just an example):

from sanic import Sanic
from sanic.response import json

app = Sanic("name")

@app.route("/")
async def test(request):
  return json({"hello": "world"})
def main(host_ = "0.0.0.0", port_ = 9000):
    if __name__ == "__main__":
        app.run(host=host_ , port=port_ )

I need to do pytest to check whether my function returns json file or not. How could i do it in this case when its a web app?

Aucun commentaire:

Enregistrer un commentaire