Reputation: 22804
I followed how to contribute to Flask tutorial.
When I run pytest tests/*.py
, the tests pass but when I run simply pytest
(as asked on the reference above), I get this error message:
pytest
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /home/begueradj/flask, inifile: setup.cfg
collected 377 items / 3 errors
==================================== ERRORS ====================================
____________ ERROR collecting examples/flaskr/tests/test_flaskr.py _____________
ImportError while importing test module '/home/begueradj/flask/examples/flaskr/tests/test_flaskr.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
examples/flaskr/tests/test_flaskr.py:15: in <module>
from flaskr import flaskr
E ImportError: No module named 'flaskr'
__________ ERROR collecting examples/minitwit/tests/test_minitwit.py ___________
ImportError while importing test module '/home/begueradj/flask/examples/minitwit/tests/test_minitwit.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
examples/minitwit/tests/test_minitwit.py:14: in <module>
from minitwit import minitwit
E ImportError: No module named 'minitwit'
_____ ERROR collecting examples/patterns/largerapp/tests/test_largerapp.py _____
ImportError while importing test module '/home/begueradj/flask/examples/patterns/largerapp/tests/test_largerapp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
examples/patterns/largerapp/tests/test_largerapp.py:1: in <module>
from yourapplication import app
E ImportError: No module named 'yourapplication'
!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 3 error in 2.78 seconds ============================
My environment is:
Why did this occur and how to fix it?
Upvotes: 1
Views: 264
Reputation: 127410
Now that Flask 1.0 is out, pytest
alone will only run the tests in the tests
directory. After installing the examples, use pytest tests examples
to test both.
pip install -e examples/tutorial
pip install -e examples/javascript
pytest tests examples
The contributing docs are were out of date, you need to run pytest tests
. If you want to test the examples (which is what's failing now) you need to install them like tox
does.
pip install -e examples/flaskr
pip install -e examples/minitwit
pip install -e examples/patterns/largerapp
pytest
Alternatively, run tox -e py
to run the entire test suite, or tox
to run the suite on all supported Python versions.
Upvotes: 2