Skip to content

Commit 57d8b49

Browse files
committed
test: configure pytest for VS Code
This will allow developers using VS Code to automatically detect, run, and deubg their tests using VS Code's Testing bar. To do this, we're explicitly passing --ds=test_settings to point pytest-django at the correct settings. Note that creating a pytest.ini file and adding DJANGO_SETTINGS_MODULE to it won't work for most developers who will be running these tests under Tutor. That's because Tutor will set the environment variable DJANGO_SETTINGS_MODULE for LMS or Studio (CMS), and this takes precedence over pytest.ini. This commit also starts a pattern for allow-listing specific configuration files in the .vscode directory. This is going to be a balancing act where we want to add just a few things that should be universally shared for convenience, like how to run tests or attach debugging to a running process. While VS Code does store user-specific settings elsewhere, individual developers may be running many plugins that put their own data in this directory.
1 parent 2644032 commit 57d8b49

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,15 @@ requirements/private.txt
6464
# database file
6565
dev.db*
6666

67-
.vscode
67+
# virtualenv
6868
venv/
6969

70+
### Visual Studio Code ###
71+
# Generally ignore VS Code configuration, except...
72+
.vscode/*
73+
# included for test settings, so VS Code's Testing bar works out of the box
74+
!.vscode/settings.json
75+
7076
# Media files (for uploads)
7177
media/
7278

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"python.testing.unittestEnabled": false,
3+
"python.testing.pytestEnabled": true,
4+
"python.testing.pytestArgs": [
5+
"--ds=test_settings",
6+
],
7+
}

0 commit comments

Comments
 (0)