Skip to content

Problem to recognize tests with @pytest.mark.parametrize decorator inside class #947

Closed

Description

@roschel

Let's see if I'll get some answers this time, because my first issue was ignored #785

Hello guys.

I've been facing some problems here when trying to debug tests that is decorated with parametrize.

Image

VsCode can't recognize these tests with parametrize from pytest.

my .vscode/settings.json:

{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
My VsCode version: 1.103.1

So, The problem is that the run/debug button from vscode doesn't appear when the test is decorated with @pytest.mark.parametrize.

According with the picture I attached, the first test, which is decorated, doesn't have the run/debug enabled. While the second test without the decorator has the run/debug button enabled.

Why this happen in vscode?

Does anyone know how to resolve this problem?

Activity

  1. rchiodo commented on Feb 5, 2026

    @rchiodo
    Contributor

    Works for me. Not sure what the difference is.

    Image

    But if you look in the Testing panel, that test has to be listed there to be debuggable.

    Image

    This failure wouldn't be with the debug extension though. It should be with the Python base extension as it does the test analysis. The debugger extension doesn't even know about pytest tests.

    I believe that code is in the test discovery in the vscode-python extension.

  2. roschel commented on Feb 5, 2026

    @roschel
    Author

    Rich Chiodo (@rchiodo) Even though your method has the 'self' as argument, it doesn't look like to be a method class because it doesn't have identantion enough. Are you sure you tested it as a method class?

    Why I can not reopen this issue?! The answer from Rich Chiodo (@rchiodo) is not clear enough for me.

  3. rchiodo commented on Feb 5, 2026

    @rchiodo
    Contributor

    I didn't try as a method class, but that works for me too.

    Image

    The bug here is not in the vscode-python-debugger extension though. It doesn't provide these debug buttons. The vscode-python extension does.

  4. rchiodo commented on Feb 5, 2026

    @rchiodo
    Contributor

    The likely root cause (in my opinion) is the test discovery that the vscode-python extension is doing. You can look at logs for that somewhere in the Output terminal and see what tests it discovers.

    Whatever tests it discovers should show up in the Test panel:

    Image

    I know pytest can be finicky though. You can't have any problems in the code that might cause a runtime problem. That will prevent it from identifying tests.

  5. roschel commented on Feb 5, 2026

    @roschel
    Author

    Rich Chiodo (@rchiodo) thank you so much, this was a very useful answer!
    I will look around the problem in the vscode-python repository.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage-neededNeeds assignment to the proper sub-team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions