Error: Test result not found when using parameterized fixtures
See original GitHub issueEnvironment 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:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
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.
@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