- Added "python.djangoTestRunner.prefixWithProjectName" setting to optionally disable prefixing method/class/file/app name with the project name
- e.g. If this test runner runs the command "python ./manage.py MyProject.MyApp.ThisFile.ThisClass.ThisMethod" by default, it will run "python ./manage.py MyApp.ThisFile.ThisClass.ThisMethod" if the prefixWithProjectName command is false
- clone this repo using your preferred git workflow
- You can skip the next 3 steps if you use the .vsix file from the repo
cd {the-newly-cloned-repo}pnpm installornpm installto install the necessary packagesnpx vsce packageto build the .vsix file- Uninstall Django Test Runner extension (if you have it installed already)
- Install this extension from the vsix file
- tl;dr extensions sidebar -> 3 dot menu in the top right -> Install from VSIX... -> select the .vsix file that was just built (likely {the-newly-cloned-repo}/django-test-runner-3.0.3.vsix)
- Make changes to the code
- Run
npx vsce packageto rebuild - Uninstall Django Test Runner extension
- Reinstall from .vsix
Adds support for running Django tests in Visual Studio Code. Provides shortcuts to run closest method, class, file, app and previous tests. Provides support for Django-Nose in settings. Draws inspiration from vscode-django-tests and vim-python-test-runner.
Default shortcuts:
Run Closest Test Method: cmd+d+m extension.djangoTestRunner.runMethodTests
Run Closest Test Class: cmd+d+c extension.djangoTestRunner.runClassTests
Run Current Test File: cmd+d+f extension.djangoTestRunner.runFileTests
Run Current App Tests: cmd+d+a extension.djangoTestRunner.runAppTests
Run Previous Tests: cmd+d+p extension.djangoTestRunner.runPreviousTests
VSCodevim keybindings (put these in your settings.json file):
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["leader", "d", "m"],
"commands": ["python.djangoTestRunner.runMethodTests"]
},
{
"before": ["leader", "d", "c"],
"commands": ["python.djangoTestRunner.runClassTests"]
},
{
"before": ["leader", "d", "f"],
"commands": ["python.djangoTestRunner.runFileTests"]
},
{
"before": ["leader", "d", "a"],
"commands": ["python.djangoTestRunner.runAppTests"]
},
{
"before": ["leader", "d", "p"],
"commands": ["python.djangoTestRunner.runPreviousTests"]
}
],
Requires manage.py to be in the root workspace directory, otherwise add a cd command to the python.djangoTestRunner.prefixCommand settings such as "cd ~/Projects/hello-world/src &&"
This extension contributes the following settings:
python.djangoTestRunner.djangoNose: if checked will use django-nose syntax for running class/method tests inside a file, defaults to non-nose testing syntaxpython.djangoTestRunner.flags: any flags you wish to run such as --nocapture, also useful for specifying different settings if you use a modified manage.pypython.djangoTestRunner.prefixCommand: any command(s) to be directly before the main test command e.g. "cd ~/Projects/hello-world/src &&" to cd into the directory containing your manage.pypython.djangoTestRunner.prefixWithProjectName: optionally disable prefixing method/class/file/app name with the project name- e.g. If this test runner runs the command "python ./manage.py MyProject.MyApp.ThisFile.ThisClass.ThisMethod" by default, it will run "python ./manage.py MyApp.ThisFile.ThisClass.ThisMethod" if the prefixWithProjectName command is false
- Default shortcuts may or may not work and require setting them manually
Open a issue/feature request and more at the github repository
Adds support for running Django Tests a multitude of ways such as by method or class. Supports Django-Nose syntax, test flags, and prefix commands.
Initial release of Django Test Runner