microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

Test Explorer fails to find results of tests marked with `xdist_group` #23619

Open vludax opened 5 months ago

vludax commented 5 months ago

Type: Bug

Behaviour

Tests marked with xdist_group execute as expected in VS Code, just as they do via the CLI. However, VS Code fails to report their results.

This is the same issue as described here: https://github.com/microsoft/vscode-python/issues/19374

Extension version: 2024.8.1 VS Code version: Code 1.90.0 (Universal) (89de5a8d4d6205e5b11647eb6a74844ca23d2573, 2024-06-04T19:34:44.157Z) OS version: Darwin arm64 23.5.0 Modes:

User Settings

``` languageServer: "Pylance" testing • pytestArgs: "" • pytestEnabled: true experiments • optInto: ["pythonTestAdapter"] ```

Installed Extensions |Extension Name|Extension Id|Version| |---|---|---| |autoDocstring - Python Docstring Generator|njpwerner.autodocstring|0.6.1| |Better Jinja|samuelcolvin.jinjahtml|0.20.0| |Code Spell Checker|streetsidesoftware.code-spell-checker|3.0.1| |EditorConfig for VS Code|EditorConfig.EditorConfig|0.16.4| |Even Better TOML|tamasfe.even-better-toml|0.19.2| |Git Graph|mhutchie.git-graph|1.30.0| |GitHub Copilot|GitHub.copilot|1.202.0| |GitHub Copilot Chat|GitHub.copilot-chat|0.16.1| |GitLens — Git supercharged|eamodio.gitlens|15.1.0| |JavaScript Debugger|ms-vscode.js-debug|1.90.0| |JavaScript Debugger Companion Extension|ms-vscode.js-debug-companion|1.1.2| |Jinja|wholroyd.jinja|0.0.8| |json|ZainChen.json|2.0.2| |Jupyter|ms-toolsai.jupyter|2024.5.0| |markdownlint|DavidAnson.vscode-markdownlint|0.55.0| |Pylance|ms-python.vscode-pylance|2024.6.1| |Python|ms-python.python|2024.8.1| |Python Debugger|ms-python.debugpy|2024.6.0| |Python Environment Manager|donjayamanne.python-environment-manager|1.2.4| |Python Indent|KevinRose.vsc-python-indent|1.18.0| |Ruff|charliermarsh.ruff|2024.26.0| |Terraform|4ops.terraform|0.2.5| |YAML|redhat.vscode-yaml|1.15.0| |YAML ❤️ JSON|hilleer.yaml-plus-json|1.12.2|
eleanorjboyd commented 4 months ago

Hello! Apologies for the delay I will look into this!

eleanorjboyd commented 4 months ago

Hi! Gave this a try and it worked for me using the steps in the issue you linked. Can you confirm you are on the rewrite or send over your logs? If you are on the rewrite and it still is not working can you send me steps to see what you are seeing. Thanks!

vludax commented 4 months ago

Hi @eleanorjboyd, I've tried to reproduce it with the steps in #19374, and it worked fine. However, it still failed with my code. The issue seems to come up when we combine the xdist_group and the parametrize marks for the same tests. Here is a simple way to reproduce it:

test_repro.py:

import pytest

@pytest.mark.xdist_group("groupA")
@pytest.mark.parametrize("x", [True, False])
def test_bar(x):
    assert x

.vscode/settings.json:

{
    "python.testing.pytestArgs": [
        "-n",
        "auto",
        "--dist",
        "loadgroup",
    ]
}

Not quite sure if I'm on the rewrite -- how can I check?

eleanorjboyd commented 3 weeks ago

you can confirm its enabled by finding Experiment 'pythonTestAdapter' is active in your python logs. If you are unable to see the log for the experiment change your log level to trace and it should show up.To set to trace use theDeveloper: set log level command in the command palette. If you aren't on it add this setting to your users settings.json "python.experiments.optInto": ["pythonTestAdapter"].

If that doesn't help then I will mark this for later as I am taking a look at different pytest plugins which aren't compatible with the vscode testing infrastructure and revisit it then.