Why does security.py not correctly evaluate the Flask server command?

I am trying to figure out which lines of a Flask application are running. I run Flask as follows:

coverage run manage.py runserver 

The result is as follows:

  * Running on http://127.0.0.1:5000/ * Restarting with reloader 

manage.py looks like this:

 #!/usr/bin/env python from flask.ext.script import Manager from my_flask_app import app manager = Manager(app) if __name__ == '__main__': manager.run() 

Then I access the various parts of the application through HTTP.

When I look at the HTML coverage report, it says that only method definitions are considered, not the actual method bodies.

I suspect this because the methods are executed by a subprocess that is not covered by cover.py.

Any ideas?

+8
python flask coverage.py
source share
1 answer

So it turns out that the problem is with the 'reloader' message above. The coverage report is correct if I run Flask instead:

 coverage run manage.py runserver -R 

The output then contains only the following:

 * Running on http://127.0.0.1:5000/ 

Thus, it does not start the server in a separate process, and coverage works fine.

I found this solution thanks to this Django related question:

Why doesn't .png cover correctly measure Django launch server command?

+7
source share

All Articles