python - 设置 pycharm 运行 django unittest

标签 python django unit-testing pycharm django-unittest

I can not run Django Python pytest under PyCharm
在我从上面的 URL 得到答案之后。我现在正在尝试尽可能多地利用我的 IDE 功能。
这是我公司的另一个使用 Django UnitTest 的项目。这是我使用的命令行。

$ python manage.py test --settings=eneos.config.settings.local

实际上 --settings=eneos.config.settings.local 不是必需的,因为我已经将该配置放在了 wsgi.py 中。但是当我问这个问题时,明确的总比隐含的好。

enter image description here

不幸的是。它不像 pytest 那样简单。我必须在这里遗漏一些要点。

窗口中的前几行。

/Users/el/.pyenv/versions/eneos-pos-web/bin/python "/Users/el/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/171.4694.38/PyCharm.app/Contents/helpers/pycharm/_jb_unittest_runner.py" --path .
Testing started at 2:17 PM ...
Launching unittests with arguments python -m unittest discover -s . -t /Users/el/Code/eneos-pos-web in /Users/el/Code/eneos-pos-web
Error
Traceback (most recent call last):

enter image description here

更新: enter image description here 它曾经用感叹号问我,让我修复右下角的路径。只需将工作目录和配置文件放在询问表单中即可。

enter image description here 完成!

最佳答案

有一个Django tests run configuration.

Django tests

使用它,您可以设置特定于 Django 的选项; 自定义设置,例如。

关于python - 设置 pycharm 运行 django unittest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44868381/

相关文章:

python - Pandas 将行除以总数

ruby-on-rails - Sentry Rails 客户端

c++ - 使用 C++ Builder 可以替代 DUnit 吗?

eclipse - 在命令行上使用gradle运行时,junit运行正常,但作为junit测试,无法在eclipse上运行

python - 如何将用户输入的数字添加到我的文本文件列表中?

python - 计算子串出现的次数

python - 更改默认的 auth_user 表名

python - Django密码更改:Reverse for '<function password_change_done at 0xa3b0f0c>' with arguments '()' and keyword arguments '{}' not found

django - Ubuntu 服务 Upstart 或 SystemD,Django 开发服务器即服务

php - Laravel & mock : Unit testing the update method without hitting the database