PyCharm & tests/runtests.py

190 views
Skip to first unread message

l...@damoti.com

unread,
Dec 10, 2016, 9:35:14 AM12/10/16
to Django developers (Contributions to Django itself)
Hello,

Does anyone here use PyCharm to hack on django? How do you run the unit tests? Specifically, PyCharm has its own runner and django has it's own runner in tests/runtests.py.

It appears that the main thing I need from runtests.py is the settings. Is there a good way to extract the necessary things from runtests.py into a custom settings file so that the django tests could be run without runtests.py (and instead with an IDE)?

My goal is to be able to click on specific tests in the PyCharm IDE and either run or debug them.

Thank you,

 Lex

l...@damoti.com

unread,
Dec 10, 2016, 11:20:17 AM12/10/16
to Django developers (Contributions to Django itself)
Somewhat related follow up question:

I have added a new model to django/tests/postgres/models.py, how do I now run makemigrations to generate a new migration for this model? Since the settings necessary to work with the test scaffolding is embedded in runtests.py I can't figure out how to use any of the django-admin commands on the test apps.

Any help would be greatly appreciated.

Tim Graham

unread,
Dec 10, 2016, 2:18:23 PM12/10/16
to Django developers (Contributions to Django itself)
Please add new operations to the existing migrations manually. See a previous commit on the file for an example: https://github.com/django/django/commit/094d630ae8d8e5e68817c313da0fd737898b216b

I'm not a PyCharm user so I'm not sure about that part.

Vimarsh Chaturvedi

unread,
Dec 22, 2016, 7:27:18 AM12/22/16
to Django developers (Contributions to Django itself)
Hey Lex, 

To run the tests in PyCharms I followed the following steps: 
1) In Run -> Edit Configurations, I created a new Configuration. 
2) In the script field I gave the path to the runtests.py file and gave script parameter as one of the test files since I only wanted to run the tests present in one directory.
3) I gave the name as 'runtests'. 

After applying the changes "Run 'runtests' " & "Debug 'runtests' " were available in the Run menu. 

Hope that helps. 
Reply all
Reply to author
Forward
0 new messages