Skip to content

Error: Test result not found when using parameterized fixtures #17079

Closed
@dasturge

Description

@dasturge

Environment data

  • VS Code version: 1.59.0
  • Extension version (available under the Extensions sidebar): v2021.9.1137256656-dev
  • OS and version: Ubuntu 18.04
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.8.10, conda 4.10.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: pytest 6.2.4
  • Relevant/affected Python-related VS Code extensions and their versions: Python (version above)
  • Value of the python.languageServer setting: Pylance

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

I'm using a parameterized fixture for my package, which runs tests against a group of valid configuration files

# tests/conftest.py
import pytest
import yaml

approved_config_list = [
    "experiments/config.yml",
    "experiments/model_v1.0.yml",
]

@pytest.fixture(params=approved_config_list)
def config(request):
    with open(request.param) as fd:
        cfg = yaml.safe_load(fd)
    return cfg

Actual behaviour

All of my tests are passing, however, for each parameterized test I get something like:

Test result not found for: ./tests/test_postprocessing.py::TestPostprocessing::test_input_type[experiments/config.yml]

If I remove the parameterization here then the testing sidebar finds all of the test results just fine and confirms they all succeeded. The test log output also has no issues and says everything passed.

Steps to reproduce:

I think writing some simple pytests with these files should reproduce this and also use the same characters in the params in case it's a special character issue.

# tests/conftest.py
import pytest
import yaml

approved_config_list = [
    "experiments/config.yml",
    "experiments/model_v1.0.yml",
]

@pytest.fixture(params=approved_config_list)
def config(request):
    with open(request.param) as fd:
        cfg = yaml.safe_load(fd)
    return cfg
# tests/test_file.py

class TestConfig:
    def test_config(self, config):
        assert isinstance(config, dict)
# experiments/config.yml
attr1: 1
attr2: 2

# experments/model_v1.0.yml
attr1: 1
attr2: 3
# .vscode/launch.json
{
    "python.testing.pytestEnabled": true,
    "python.testing.pytestArgs": [
        "tests"
    ],
}

Metadata

Metadata

Assignees

Labels

area-testingbugIssue identified by VS Code Team member as probable bugregressionBug didn't exist in a previous release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions