/
VSCode

VSCode

Pytest Integration

To configure pytest tests in VSCode:

  1. Install the Python Extension for VSCode
  2. Run the Python: Configure Tests command
  3. In Settings > Python > Testing: Pytest Args, add the --no-cov argument
  4. Run the Python: Discover Tests command
  5. This adds the Run Test | Debug Test buttons in VSCode with breakpoint integration

Alternatively, edit settings as follows, then run Python: Discover Tests

pytest settings
{
    "python.testing.unittestEnabled": false,
    "python.testing.nosetestsEnabled": false,
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": [
        "--no-cov"
    ]
}

Resources: 

Pylint in edx-platform

The Python plugin (published by Microsoft) has pylint support. The tricky bit is that you have to install all of the requirements in a local virtualenv, because pylint imports the python files to analyze them. So, in edx-platform, you'd need to make a virtualenv, pip install -r requirements/edx/development.txt, and then in VSCode, you need to

  1. set your virtualenvironment root (Python: Venv Path in user settings)
  2. set your workspace interpreter (Python: Select Interpreter in the command window [Ctrl + Shift + p])

Due to edx-platform sys.path stuff, you should also add stuff to the path that VSCode knows about by setting the following in your Workspace Settings

python.autoComplete.extraPaths": [
	"lms/djangoapps/",
	"cms/djangoapps/"
]

Related content

Setup mockprock as a backend
Setup mockprock as a backend
More like this
Development Tools
Read with this
Thoughts on Tests
More like this
Configuring your editor for ES2015 and JSX
Configuring your editor for ES2015 and JSX
Read with this
edx-platform unit tests migration from Jenkins to Github Actions
edx-platform unit tests migration from Jenkins to Github Actions
More like this