I’m trying to not only use Django but also understand the code of the framework. Usually, when I’m with a codebase that I don’t know, I run the tests, change things to see what happen and put a breakpoint and inspect the variables, … I use Pycharm to do that. But one problem I have with the Django code is that I don’t know how to configure Pycharm to run the tests.
I suppose the problem is related to the fact that Django tests are run through the script runtests.py . Has anyone run the Django tests with Pycharm? I’m mean to run the tests of the Django framework itself, I’m able to run the tests of projects that use Django without a problem.
If you’re using the community edition, then you can create a regular Python run configuration. Here is one that I just tested successfully. Do note that I am running this in Docker, hence my Python interpreter looks a bit funny. I can’t see why it wouldn’t work with a local Python interpreter.
Thanks for the response but I think I expressed myself wrong. I can run tests with Pycharm for a project y create using Django (where I add apps, models, …). But I can not configure Pycharm to run the tests of the Django project, for example, these https://github.com/django/django/blob/master/tests/asgi/tests.py
My purpose is to debug the tests, change the code to see what happens …
You can set up a “Python” run/debug configuration on the script tests/runtests.py. This will let you run all (or a subset) of Django’s tests in PyCharm’s run window, and also let you use PyCharm’s integrated debugger on the tests.
Just to be clear: this is for working inside Django’s own codebase (you forked github django/django). If you’re trying to use PyCharm with your own Django project, Conor’s earlier answer will give much better results.
(Unfortunately, I can’t get it to use PyCharm’s nifty test runner tabs for the runtests.py output. If anyone figures that out, please post it.)