3

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!

falsetru
  • 357,413
  • 63
  • 732
  • 636
joe
  • 8,383
  • 13
  • 61
  • 109

1 Answers1

1

There is a Django tests run configuration.

Django tests

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

falsetru
  • 357,413
  • 63
  • 732
  • 636
  • Holy Sh.t. I was reading on this https://docs.djangoproject.com/en/1.11/topics/testing/overview/ and it direct me to `unittest`!. Hold on one moment. I will get back to forum – joe Jul 02 '17 at 07:30
  • But that is only for professional edition tho – swdev Feb 13 '21 at 22:14
  • @swdev,Yes, only professional edition support python web frameworks. https://www.jetbrains.com/pycharm/features/editions_comparison_matrix.html – falsetru Feb 14 '21 at 02:04
  • @falsetru for now I think I am quite satisfied with pytest-django in pycharm community. no click on error source code level, but good enough. At least there is an UI for that – swdev Feb 15 '21 at 04:30