python - 我无法在 PyCharm 下运行 Django Python pytest

标签 python django pycharm pytest pytest-django

$ 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

我已经安装 pytest-djangopyenv已经。然后我想研究 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在我的测试中。非常感谢。

最佳答案

而不是使用 python , 您应该使用 Python tests > py.test :

py.test configuration on PyCharm

更新

您过滤了测试结果以仅显示跳过的测试。切换绿色按钮也将显示成功的测试。

toggle this buttons

关于python - 我无法在 PyCharm 下运行 Django Python pytest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44868078/

相关文章:

python - 在 Django ORM 的单个请求中获取一个相关对象

python - 如何从 Django 中的外键值取平均值?

python - 如何将mininet模块添加到pycharm?

python - Errno 13 权限在 mac 上被拒绝

python - 将 yerr/xerr 绘制为阴影区域而不是误差线

python - 使用 SQLAlchemy (Python) 创建模型对象时生成 GUID

python - 如何通过某个键出现的次数来 "sort"字典?

django - 如何将 django_migrations 表注册到 django-admin 面板

python - 做 a = b + a 有什么更好的方法吗?

python - 当向控制台写入回车时,整行都被删除了吗?