diff --git a/.gitignore b/.gitignore index 0f071cb7a..6123dd4cf 100644 --- a/.gitignore +++ b/.gitignore @@ -64,9 +64,16 @@ requirements/private.txt # database file dev.db* -.vscode +# virtualenv venv/ +### Visual Studio Code ### +# Generally ignore VS Code configuration, except... +.vscode/* +# Example settings to let people quickly get up to speed with testing. +!.vscode/launch.json.example +!.vscode/settings.json.example + # Media files (for uploads) media/ diff --git a/.vscode/launch.json.example b/.vscode/launch.json.example new file mode 100644 index 000000000..bcb36d102 --- /dev/null +++ b/.vscode/launch.json.example @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Debug Tests", + "type": "debugpy", + "request": "launch", + "program": "${file}", + "purpose": ["debug-test"], + "console": "integratedTerminal", + "justMyCode": false, + + // This is needed because pytest-cov is incompatible with using the + // debugger. See https://code.visualstudio.com/docs/python/testing#_pytest-configuration-settings + "env": {"PYTEST_ADDOPTS": "--no-cov"}, + + // Adds some magic for Django templates. + "django": true + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json.example b/.vscode/settings.json.example new file mode 100644 index 000000000..04f8cb628 --- /dev/null +++ b/.vscode/settings.json.example @@ -0,0 +1,14 @@ +{ + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": [ + // We have to override this here instead of in pytest.ini because tutor + // sets the DJANGO_SETTINGS_MODULE env variable in our container to be + // the one for LMS or Studio, and that takes precedence over any value + // set in pytest.ini. The only thing that takes higher precedence than + // the env variable is the explicit command line parameter: + // + // https://pytest-django.readthedocs.io/en/stable/configuring_django.html#order-of-choosing-settings + "--ds=test_settings" + ], +} \ No newline at end of file diff --git a/README.rst b/README.rst index 9d82684e4..b2be0c147 100644 --- a/README.rst +++ b/README.rst @@ -108,6 +108,15 @@ Every time you develop something in this repo # Open a PR and ask for review. +Configuring Visual Studio Code +------------------------------ + +If you are using VS Code as your editor, you can enable the Testing bar by copying from the example configuration provided in the ``.vscode`` directory:: + + cd .vscode/ + cp launch.json.example launch.json + cp settings.json.example settings.json + License -------