3

Resolved

Support Django Unit Test?

description

I am new to Django and PTVS (but not Visual Studio or Python) and I am trying to get into the Web world of Python and I noticed in the demos you can do Unit testing. As far as I know, there is not a way to do the unit test for Django (well, I can change the launch mode to Standard Python and use "test app" for the arguments). I am sure adding in the integrated testing support that the python unit test for Django would probably be more difficult, so i was thinking just add a menu option when you right-click the project to run test and make it do "python manage.py test" in an Command Window like when you do SyncDB or Validate.

comments

olivergeorge wrote May 4 at 2:46 AM

I had a quick play and found that you could get around that problem by adding this to the visualstudio_py_testlauncher.py file:
try:
    from django.conf import settings
    if not settings.configured:
        settings.configure()
except:
    pass
Perhaps we need a django specific test launcher?

Zooba wrote Jun 25 at 6:00 PM

We really just need to flow the environment variable through to the test executor. Ideally we would have a generic "environment variable" property that Django would automatically fill with the DJANGO_SETTINGS_MODULE value, but for now we can flow through that individual value.

At least it will make it easier to support tests later when we have a chance to add proper environment variable support.