Search code examples
pythondjangounit-testingpycharmdjango-unittest

Setting pycharm run django unittest


I can not run Django Python pytest under PyCharm
After I got the answer from the above URL. I am now trying to fully utilize my IDE functions as much as I can.
Here is another project in my company that using Django UnitTest. This is the command line I used.

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

Actually --settings=eneos.config.settings.local is not required, because I put that config in the wsgi.py already. But explicit is better than implicit when I ask the question.

enter image description here

Unfortunately. It is not simple like pytest. I must miss some points in here.

First several lines in the window.

/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

Update: enter image description here It used to ask me with Exclamation mark and let me fix the path in the bottom right. Just put working directory and configuration file in the asking form.

enter image description here Done!


Solution

  • There is a Django tests run configuration.

    Django tests

    Using that, you can set Django-specific options; Custom settings, for example.