I can not run Django Python pytest under PyCharm

2019-08-11 14:00发布

问题:

$ pytest portal/
=============================================== test session starts ===============================================
platform darwin -- Python 3.6.0, pytest-3.0.6, py-1.4.32, pluggy-0.4.0
Django settings: config.settings.local (from ini file)
rootdir: /Users/el/Code/siam-sbrand/portal, inifile: pytest.ini
plugins: django-3.1.2
collected 87 items

portal/apps/commons/tests.py ......
portal/apps/price_list_excel_files/tests.py ssssssssssss
portal/apps/price_lists/tests.py s....
portal/apps/reports/tests.py .........................ssss..................
portal/apps/sbrand_jobs/tests.py ................
portal/apps/service_items/tests.py s

===================================== 69 passed, 18 skipped in 32.08 seconds ======================================

pytest.ini:

[pytest]
DJANGO_SETTINGS_MODULE=config.settings.local
norecursedirs = node_modules venv *.txt
python_files = tests.py Test*.py test_*.py

I have install pytest-django under pyenv already. Then I want to study key feature in PyCharm, but unfortunately when I try reaching the JetBrain forum. It is limited to the company owner only. I can not post my question because I just an employee.

And this is when I click play pytest button

/Users/el/.pyenv/versions/siam-sbrand/bin/python pytest portal
/Users/el/.pyenv/versions/siam-sbrand/bin/python: can't open file 'pytest': [Errno 2] No such file or directory

Process finished with exit code 2

**Update refer to falsetru answer

Yeah! It works like a PyCharm. It is not green light because I put decorator skip in my test. Thank you very much.

回答1:

Instead of using python, You should use Python tests > py.test:


UPDATE

You filtered test result to show only skipped test. Toggle green button will show also successful tests.