-
-
Notifications
You must be signed in to change notification settings - Fork 502
Testing
Kyle Gabriel edited this page Sep 20, 2019
·
8 revisions
- Attach your virtual environment
source ~/Mycodo/env/activate
- move into the
Mycodo/mycodo
directory
cd ~/Mycodo/mycodo
- call pytest through the python command using the
-m
flag to set the correct python path (which avoids import errors)
../env/bin/python -m pytest -s tests/software_tests/test_mycodo_flask/test_endpoints.py
============================== test session starts ==============================
platform darwin -- Python 2.7.11, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /Users/username/PycharmProjects/Mycodo/mycodo, inifile:
collected 7 items
tests/software_tests/test_mycodo_flask/test_endpoints.py .......
============================== 7 passed in 1.00 seconds ==============================
- Later have a look at pytest's
--help
command for more info. The command shown above just tells pytest to run everything in thetest_endpoints.py
module.
- Move into the
Mycodo/mycodo
directory with your virtual environment attached - Just like the previous command, we call pytest using the
python -m
command, but this time we use pytest's-k
flag to only run tests that match an expression. In this case, let's run thetest_user_can_login
function.
../env/bin/python -m pytest -s tests/software_tests/test_mycodo_flask/test_endpoints.py -k test_user_can_login
============================== test session starts ==============================
platform darwin -- Python 2.7.11, pytest-3.0.3, py-1.4.31, pluggy-0.4.0
rootdir: /Users/username/PycharmProjects/Mycodo/mycodo, inifile:
collected 7 items
tests/software_tests/test_mycodo_flask/test_endpoints.py .
============================== 6 tests deselected ==============================
============================== 1 passed, 6 deselected in 0.73 seconds ==============================