Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
24 changes: 24 additions & 0 deletions .vscode/launch.json.example
Original file line number Diff line number Diff line change
@@ -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
}
Comment on lines +7 to +22
Copy link
Contributor

@bradenmacdonald bradenmacdonald Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This launch config isn't working for me for some reason - when I run it via the "Run and Debug" panel with a test file open, it gives No module named 'openedx_learning' despite using the correct venv which has that installed. But I'm wondering why we even need this launch configuration? Because the "Debug Test" buttons on the "Testing" panel are working just fine for me already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I've always been running it from the "Testing" panel where it works. But I see the same issues as you in the Run/Debug panel. I'll look into that, thank you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't think it was affecting the "Testing" panel but now I can see that when I have this code in place it runs the debug mode tests differently. For me the "debug test" button works fine either with or without this launch.json config. The only difference I can see is that with the config in place, it produces more output in the terminal.

I don't think it's an issue that it doesn't also work from "Run and Debug", as long as other people aren't confused like I was.

]
}
14 changes: 14 additions & 0 deletions .vscode/settings.json.example
Original file line number Diff line number Diff line change
@@ -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"
],
}
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------

Expand Down