[TIP] Testing Flask apps in a pyvenv environment
Paradox
paradox at pobox.com
Wed Jul 8 20:33:25 PDT 2015
I am trying to learn TDD using the tutorial here:
https://github.com/mjhea0/flaskr-tdd
The only thing I have done differently from the tutorial is to use
pyvenv rather than virtualenv and to use py.test for my test runner.
When I get to the point of running the first test (on returning the
"Hello, World!" page) the second time (after the app.py file is created
and filled) it still fails as follows:
app-test.py:1: in <module>
from app import app
app.py:1: in <module>
from flask import Flask
E ImportError: No module named 'flask'
Running the flask app works fine, it starts the development server and
returns the proper page, there seems to be something wrong with the test
file or the test runner.
Incidentally when I run the test without py.test it finds the module but
fails with an error in the returned string:
AssertionError: b'Hello, World!' != 'Hello, World!'
I haven't figured that one out yet either!
Is there a reason py.test can't find the flask module in the pyvenv
created virtual environment?
thomas
===============
Thomas C. Hicks, MD, MPH
Training Manager
Gansu Gateway, Lanzhou, Gansu
More information about the testing-in-python
mailing list