vscode-python-test-adapter: [pytest] test states not displayed
When using pytest the icons in the test explorer remain gray (no matter if tests fail or pass).
The output shows the following (I had to mask actual paths and names):
2023-01-25T15:28:40.343Z INFO pytest at 'xyz': Reading configuration for workspace xyz
2023-01-25T15:28:40.344Z DBG pytest at 'xyz': usingNewInterpreterStorage feature flag is 'true'
2023-01-25T15:28:40.344Z INFO pytest at 'xyz': Using auto-detected pythonPath /<path>/python
2023-01-25T15:28:40.345Z INFO pytest at 'xyz': Running tests using python path '/<path>/python' in /<path>/xyz
2023-01-25T15:28:40.346Z INFO pytest at 'xyz': Loading environment variables file /<path>/xyz/.env
2023-01-25T15:28:40.352Z INFO pytest at 'xyz': Running pytest with arguments: --rootdir=/<path>/xyz, --junitxml=/<tmp-path>/tmp-7245-mawg3A03U6qr, --override-ini, junit_family=xunit1, /<path>/xyz/tests/test_xyz.py::test_xyz1
2023-01-25T15:28:40.353Z INFO pytest at 'xyz': Running pytest as a Python module
2023-01-25T15:28:41.960Z INFO pytest at 'xyz': Test execution completed
When I click on “Debug this test” the following output is shown in debug terminal:
============================= test session starts ==============================
platform linux -- Python 3.11.0, pytest-7.2.0, pluggy-1.0.0
rootdir: /<path>/xyz/tests
collected 1 item
==DISCOVERED TESTS BEGIN==
{"tests": [{"id": "test_xyz.py::test_xyz1", "line": 251}], "errors": []}
==DISCOVERED TESTS END==
../../../../../../../<path>/xyz/tests/test_xyz.py . [100%]
============================== 1 passed in 1.41s ===============================
Python version is 3.11.0 (also reproducable with 3.10.4 and 3.8.3). Python Test Explorer version is 0.7.1 Running VSCode 1.74.0 on Linux (SuSE SLE15)
No problems when switching to unittest, however most of our test suite is designed for pytest. Any help would be appreciated!
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 15 (2 by maintainers)
@rcartmil Yes, I opened the workspace by navigating to the original non-symlinked path and everything started working (including the built in python test explorer, which not working was what caused me to install this extension in the first place).
@Zetaeta Wow, you are amazing! This solved my problem too! You’ve certainly made my day!
@bdovaz Thanks! I see most tests do not get the right test state in this repo. This is due to tests being defined in the parent class (LinterTestRoot) and the extension not being able to resolve the right test ID. Other tests (e.g., config_test) seems to be working fine for me.
@MichalMazurek @mayrholu Are you using parent classes for tests as well?