2017-07-02 49 views
1
下運行的Django的Python pytest
$ 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:
我不能PyCharm

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

我有安裝pyenvpytest-django了。然後我想在PyCharm中學習關鍵特性,但不幸的是當我嘗試訪問JetBrain論壇時。它僅限於公司所有者。我不能發佈我的問題,因爲我只是一名員工。

enter image description here

這就是當我點擊播放按鈕pytest

/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 

**更新參考falsetru答案 enter image description here

enter image description here

呀!它的工作原理類似於PyCharm。這不是綠燈,因爲我在我的測試中放置了裝飾者skip。非常感謝你。

回答

1

而不是使用python的,你應該使用Python tests > py.test

py.test configuration on PyCharm


UPDATE

你過濾測試結果只顯示跳過測試。切換綠色按鈕也會顯示成功的測試。

toggle this buttons

+0

好的。一會兒。我正在關注你的回覆。 – Sarit

+0

非常感謝。如果你不介意回答像我這樣的新手,我仍然有一個問題。我會更新我的帖子,並在同一問題中提問 – Sarit

+0

@Sarit,不客氣。順便說一句,你的新問題是一個相關的,但不同的問題,不是嗎?請發佈一個單獨的問題,而不是延長原始問題。 – falsetru