Skip to content

Add VSCode settings for pytest configuration #753

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tobiasdiez
Copy link
Contributor

Include settings to enable pytest in VSCode.

@dnicolodi
Copy link
Member

Does VSCode really need to add this to all projects? I don't think we should add a configuration file for every editor or IDE someone may use to work on the project.

@eli-schwartz
Copy link
Member

Does VSCode really need to add this to all projects? I don't think we should add a configuration file for every editor or IDE someone may use to work on the project.

Well, if you want vscode to automatically figure out how to run the test suite then it needs a machine readable way to figure out what test suite technology is used.

The python ecosystem has been resistant to date to defining a replacement for the setuptools test entrypoint, so there's not actually anything that vscode can do here. Piggybacking off of meson's own well-defined test command might help though.

@tobiasdiez
Copy link
Contributor Author

Does VSCode really need to add this to all projects? I don't think we should add a configuration file for every editor or IDE someone may use to work on the project.

Yes, it's needed since otherwise vscode will not recognize the existing pytests and show them in its test inferface which provides a quite convenient way to re-run only a few tests and other helpful tooling.

Piggybacking off of meson's own well-defined test command might help though.

My impression is that vscode directly calls pytest to discover tests etc.

Copy link
Contributor

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks @tobiasdiez.

This doesn't hurt and I don't think there's a better option that is generic across IDEs here (a la EditorConfig for formatting settings), so this seems okay to me.

@eli-schwartz
Copy link
Member

My impression is that vscode directly calls pytest to discover tests etc.

In theory it could use meson via vscode-meson! :)

@rgommers
Copy link
Contributor

rgommers commented Jun 2, 2025

I had a look at https://github.com/mesonbuild/vscode-meson, but not being a VSCode user, I'm not sure from the README how that would work exactly for hooking up a pytest invocation. It seems very reasonable for working on meson-python to suggest vscode-meson to VSCode users though.

@eli-schwartz
Copy link
Member

but not being a VSCode user, I'm not sure from the README how that would work exactly for hooking up a pytest invocation.

Nor me, but I assume vscode-meson allows you to configure a build with meson setup and test it with meson test.

@tobiasdiez
Copy link
Contributor Author

It's not just about running the tests (for which vscode-meson probably provides a task-integration), but also discovering all tests with detailed info (eg pytest --collect). This info is then used for https://code.visualstudio.com/docs/python/testing#_run-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants