Flask json testing 2016-05-15

The Stet.io website exlcuding the editor is often termed the backend. The backend of Stet.io is written in Python3 using the Flask framework. The backend and editor communicate via AJAX requests, sending JSON formatted data. JSON is well supported both in Flask/Python and in the web browser, making it an obvious choice.

Choosing JSON does however lead to one problem, which is how to easily test Flask-routes that expect and return JSON. The default Flask TestClient (Flask-0.10) does not have any JSON support, therefore I use the code below.

It is possible that functionality similar to that above will be present in the next release of Flask. Keep an eye on Flask-#1416 to find out, note that this pull request is not associated with Stet.io, but is provided for reference.

Back to blog