question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Test result not found when using parameterized fixtures

See original GitHub issue

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"
    ],
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jzazocommented, Sep 7, 2021

I am experiencing a similar issue in all my tests, being them parametrized with fixtures or not. I have my repo divided in multiple workspaces, so I am not sure this issue might be related to that.

0reactions
zaccharieramzicommented, Nov 22, 2021

@karthiknadig I am still experiencing this issue. I don’t have any slashed in my params. Do you want a reproducible example?

My last update is apparently (but not sure how to really check it): 04/11/2021, 19:40:15. Is it enough to have the fix to this problem?

EDIT

Sorry about that, this was just a VSCode version problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest.mark.parameterize not "finding" fixtures - Stack Overflow
I just tried your example verbatim and it worked fine in pytest 2.6.4. Perhaps you are misspelling parametrize ?
Read more >
How To Use pytest For Python Testing - Software Testing Help
Basically, this is the way to debug the code, it is easier to find the errors. Parametrization In pytest. Parametrization is used to...
Read more >
Deep dive into Pytest parametrization | by George Shuklin
I want to emphasize, pytest_generate_tests has no access to test time data whatsoever, including output values of any other fixtures or results of...
Read more >
How to parametrize fixtures and test functions - Pytest
parametrize multiple times with different parameter sets, all parameter names across those sets cannot be duplicated, otherwise an error will be raised. More ......
Read more >
Welcome to Pytest-BDD's documentation! — Pytest-BDD 6.1.1 ...
Pytest fixtures written for unit tests can be reused for setup and actions ... should not see the error message") def no_error_message(browser): with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found