Repository navigation
UI problems with tests #11497
Description
Environment data
VSCode version: 1.44.2
OS: Ubuntu 20.04, Linux x64 5.4.0-26-generic
Extension version: 2020.4.76186, using Language Server
Python: 3.7.7 using "-m venv"
Pytest version: 5.4.1, with "-vv --capture=no --showlocals --exitfirst --failed-first"
python.languageServer: Microsoft
Expected behavior
When running an individual python test file using pytest from the VSCode UI, the tests should be marked as passed.
Also when a test function is discovered, it should have "run test | debug test" links above it.
Actual behavior
Even if the tests pass, sometimes they are not marked as passed, and seem to be running forever. However the log do show that they passed.
What's more, tests can only be triggered from the side bar, as the "run test | debug test" links don't appear above the test functions.
Steps to reproduce:
I couldn't find a way to reliably reproduce the problem: I tried to setup a minimal example, but it ran correctly.
Some clues:
- The tests run with pytest from the terminal normally. They finish, and are labelled as passed
- Running all the tests from the VSCode UI works as intended
- Running individual test files from the VSCode UI may fail to mark the tests as passed
The test logs do state that the tests passed in all the cases, even when they are marked as still running:
=========================�[0m
�[1m============================= test session starts ==============================�[0m
platform linux -- Python 3.7.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 -- /home/user/.local/share/virtualenvs/ps/bin/python
cachedir: .pytest_cache
rootdir: /home/user/Work/dev_perso/postscriptum, inifile: ../../../../../media/user/shared/Work/dev_perso/postscriptum/setup.cfg
plugins: icdiff-0.4, subtests-0.3.0, testmon-1.0.2, xdist-1.31.0, cov-2.8.1, forked-1.1.3
�[1mcollecting ... �[0mcollected 2 items
run-last-failure: no previously failed tests, not deselecting items.
../../../../../../home/user/Work/dev_perso/postscriptum/::test_register_and_restore_except_handler <- ../../../../../media/user/shared/Work/dev_perso/postscriptum/tests/unit/test_excepthook.py �[32mPASSED�[0m
../../../../../../home/user/Work/dev_perso/postscriptum/::test_register_and_restore_except_handler_with_call <- ../../../../../media/user/shared/Work/dev_perso/postscriptum/tests/unit/test_excepthook.py �[32mPASSED�[0m
------------- generated xml file: /tmp/tmp-282165cdolyubcJ7t6.xml --------------
�[32m============================== �[32m�[1m2 passed�[0m�[32m in 0.10s�[0m�[32m ===============================�[0m
Here is a gif of the problem in action:

Activity
karrtikr commentedon Apr 29, 2020
Are you using pytest sugar plugin?
ksamuel commentedon May 4, 2020
No, but I'm using the following pytest plugins:
pip freeze | grep pytest pytest==5.4.1 pytest-cov==2.8.1 pytest-forked==1.1.3 pytest-icdiff==0.4 pytest-subtests==0.3.0 pytest-testmon==1.0.2 pytest-watch==4.2.0 pytest-xdist==1.31.0On this particular project, I also have the following additional options in my setup.cfg:
I assume the
--color=yesis responsible for the color code we see in the vscode output. If vscode parses the output to determine if a test is passed, that could mess it up. That wouldn't explain why the test functions don't have links above them though.karrtikr commentedon May 5, 2020
There're other extensions (for example, Liveshare) which are known to cause issues with Codelens (the links you're talking about). So please try disabling the other extensions and see if you reproduce the issue.
Yes, that's exactly what we've to do.
Unfortunately I am unable to repro this, so the only solution I can offer is that you try removing the configurations to diagnose which one of them is causing a problem.
karrtikr commentedon Jun 5, 2020
Closing as no further info was provided.