New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document steps to debug tests with vscode #12459
base: main
Are you sure you want to change the base?
Conversation
5. Conda's tests really want to run under the under-develoment version of conda, | ||
and may refuse to run at all otherwise. Add or edit `"python.condaPath": | ||
"(full path to conda in development environment)",`. | ||
> On my system, this can be found with `conda info`: `base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use "on my system" here? Are we mentioning somewhere in the docs who the author of this guide is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments and edits from someone who's never done this before. Wasn't quite able to finish either, but I'll double check the last few instructions when my initial questions are answered.
1. In a conda checkout, run `. dev/start -p 3.10` to enter a Python 3.10 (or the | ||
version you want to test) development environment. | ||
2. Open VSCode from this terminal `code`. | ||
> If `code` is not available, press `⌘-P`, `Shell` to find the `Install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it command + P? That opens a print dialog for me. I'm a bit stumped on these extra instructions, though I can open VSCode manually in order to continue looking at the rest of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to point to the menu item than the shortcut
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be more straightforward for newbies and anyone who knows how to open VSCode already via the CLI could do so if they wished.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me what works is shift + ⌘ + P
(at which point I can type in shell command
and that brings up Install 'code' command in PATH
)
2. Open VSCode from this terminal `code`. | ||
> If `code` is not available, press `⌘-P`, `Shell` to find the `Install | ||
> 'code' command in PATH` action. | ||
3. Ensure you have installed the `Python` extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe specify "in VSCode" at the end. Even though I'm in VSCode and following these instructions, my brain went blank for a second when I tried to figure out what "extension" meant in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to even include a link to the Python extension being referred to. I'm assuming it's this one? https://marketplace.visualstudio.com/items?itemName=ms-python.python
(JSON)` (the paper icon with an arrow on it, above the settings editor). | ||
5. Conda's tests really want to run under the under-develoment version of conda, | ||
and may refuse to run at all otherwise. Add or edit `"python.condaPath": | ||
"(full path to conda in development environment)",`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a placeholder standard for code snippets? In the Anaconda docs, we do <ALL-CAPS-PLACEHOLDER>, but that's pretty aggressive for a full sentence. Maybe:
"python.condaPath": "<full path to conda in your development environment>"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more notes and suggestions from my testing of these instructions.
3. Ensure you have installed the `Python` extension. | ||
4. Open settings (the gear icon in the lower left corner). Go to `Open Settings | ||
(JSON)` (the paper icon with an arrow on it, above the settings editor). | ||
5. Conda's tests really want to run under the under-develoment version of conda, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not positive about this, but I removed the python.condaPath from my settings.json, but made sure my python interpreter path was the dev environment bin and the tests worked fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great news, since having to change the global conda path is a nuisance.
Co-authored-by: Katherine Kinnaman <kkinnaman@anaconda.com>
> /Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c`, plus | ||
> `/bin/conda`, so the full setting is `"python.condaPath": | ||
> "/Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c/bin/conda",` | ||
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be helpful to include a link to the VSCode documentation for "Configure Tests"
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory. | |
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click ['Configure Tests'](https://code.visualstudio.com/docs/python/testing#_configure-tests), then choose "pytest" as your framework and "Root directory" as your test directory. |
> `/bin/conda`, so the full setting is `"python.condaPath": | ||
> "/Users/dholth/prog/conda/devenv/Darwin/arm64/envs/devenv-3.10-c/bin/conda",` | ||
6. Press the Erlenmeyer flask 'Testing' icon in the VSCode toolbar. If necessary, click 'Configure Tests', then choose "pytest" as your framework and "Root directory" as your test directory. | ||
> To reconfigure your tests, use the Command Palette to search for "Python: Configure Tests". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> To reconfigure your tests, use the Command Palette to search for "Python: Configure Tests". | |
> To reconfigure your tests, use the Command Palette (`shift + ⌘ + P`) to search for "Python: Configure Tests". |
Description
These are the steps I had to follow to debug with vscode.
Please try them out, and let me know what I've missed -- my system is already set up to do this, and there might be a few more hurdles to jump before vscode agrees to work.
Tests may be a lot easier to run than before, now that we have removed the "raises SystemExit for
menuinst
reasons, when tests are not run in a base environment" error.Checklist - did you ...
news
directory (using the template) for the next release's release notes?