kondratyev-nv / vscode-python-test-adapter

Python Test Adapter for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=LittleFoxTeam.vscode-python-test-adapter
MIT License
117 stars 27 forks source link

Added support for Django unittests #292

Closed mh-firouzjah closed 1 year ago

mh-firouzjah commented 1 year ago

Update unittestScripts.ts will help the extension to recognize the Django tests and run them with DJANGO_SETTINGS_MODULE set and also by calling django.setup() it will make sure that all django apps are load and it's ready to go for tests.

mh-firouzjah commented 1 year ago

the idea is to check if an auto-generated manage.py exists in the rootfolder and by auto-generated I mean it is generated by django-admin startproject command. existence of such a file has two messages, first this is a django project and not a pure python project so tests are expected to be django unittests and second, the content of this file can be used to figure out where is the path of the django project settings and by use of eval it will automatically set the DJANGO_SETTINGS_MODULE env variable. also I'm not sure it's enough or not, but I've added an extra line to use 'ast.literal_evaland check if the value that is going to be set forDJANGO_SETTINGS_MODULE` is a safe python expression.

mh-firouzjah commented 1 year ago

a new PR has been sent.