【问题标题】:I can not run Django Python pytest under PyCharm我无法在 PyCharm 下运行 Django Python pytest
【发布时间】:2017-07-02 06:34: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

我已经在pyenv 下安装了pytest-django。然后我想研究 PyCharm 的关键特性,但不幸的是,当我尝试访问 JetBrain 论坛时。它仅限于公司所有者。我无法发布我的问题,因为我只是一名员工。

这是当我点击播放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答案

是的!它的工作方式类似于PyCharm。这不是绿灯,因为我将装饰器skip 放在了我的测试中。非常感谢。

【问题讨论】:

    标签: python django pycharm pytest pytest-django


    【解决方案1】:

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


    更新

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

    【讨论】:

    • 好的。一瞬间。我正在关注您的回复。
    • 非常感谢。如果你不介意回答像我这样的新手,我还有一个问题。我会更新我的帖子并提出同样的问题
    • @Sarit,不客气。顺便说一句,您的新问题是一个相关但不同的问题,不是吗?请发布一个单独的问题,而不是扩展原始问题。
    • 谢谢。在点击图标的片刻之后。我发现这是我的跳过案例。
    • 我已经发布了新问题。这是相同的主题,但不同的框架。如果你想看看。 stackoverflow.com/questions/44868381/…
    猜你喜欢
    • 2020-04-25
    • 1970-01-01
    • 2017-04-04
    • 2016-03-10
    • 2021-10-20
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    • 2019-02-16
    相关资源
    最近更新 更多