[TIP] Coverage testing a Flask app running behind uWSGI?
skip.montanaro at gmail.com
Tue Mar 13 13:46:59 PDT 2018
> The idea is to consider uWSGI a detail of your server environment.
> A flask app is a Python program that exposes an object implementing the
> WSGI spec; that object is used by uWSGI to handle requests, but it can
> also be used by webtest, a library that sends requests to your app and
> inspects the responses. Add a testing framework with a test runner
> (pyunit or pytest to make life easier) and you are set.
> coverage instruments a Python program and reports coverage of some
> source files; here the program would be the test runner. uWSGI is not
> involved at all.
I should have provided more detail (a common problem I have). I use
nose to test my system (that won't change, as that's what the powers
that be have settled on), all of which eventually wind up querying the
server. I'm intuitively happy that my unit tests exercise the server,
but want to get a bit more quantitative about that.
For now, uWSGI is more than just a detail, as I implement caching and
want to test that stuff works as well.
I guess I can go back to running my test server as a plain Flask app,
but was hoping for something which could squeeze coverage in between
uWSGI and Flask.
More information about the testing-in-python