问题
i've written a few unittests for a Django project. I'd like to debug them. I've set a break point on the server side. what should I click to run the Django unittest with debugging enabled in PyDev Eclipse?
It seems I can run the manage.py test command from Pydev, but then there's no debugging. If I run the unittest with right-click debug unittest, then I get all sort Internal Server errors presumably because the test envrionment wasnt set up correctly.
回答1:
Setup a new debug configuration.
- Run -> Debug Configurations...
- Select 'PyDev Django'
- Click 'New Launch Configuration (top left corner)
- Name your new configuration
- Set the project to your project
- Set the module to your manage.py (browse to your manage.py)
- Go to the 'Arguments' tab and enter 'test' under 'Program arguments'
- Click 'Apply'
This will allow you to run 'manage.py test' and be able to stop on your breakpoints.
Unfortunately, you'll have to create different configurations if you only want to run a subset of tests.
来源:https://stackoverflow.com/questions/18424495/how-to-debug-django-unittests-with-pydev