kondratyev-nv / vscode-python-test-adapter

Python Test Adapter for the VS Code Test Explorer
https://marketplace.visualstudio.com/items?itemName=LittleFoxTeam.vscode-python-test-adapter
MIT License
117 stars 27 forks source link

[SOLVED] Tests run and pass, but hang with grey tick/check mark icon (not green) #277

Closed BrendanSimon closed 2 years ago

BrendanSimon commented 2 years ago

I have tests that run and pass but I do not get the green tick icon. When running I get the blue working icon, but then after the test completes it returns to the grey "untested" icon.

vscode Environment

Running vscode on Windows 10 Pro, connecting to Debian 10 Buster Linux VM running in VirtualBox.

Version: 1.64.2 (system setup)
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:02:28.252Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19044

Test

class Test_Dummy :
    def test_pass( self ) -> None :
        assert True == True

Debug Output:

============================= test session starts ==============================
platform linux -- Python 3.7.3, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/brendansimon/EFD/brickstrap/efd, configfile: pytest.ini
plugins: cov-3.0.0, mock-3.7.0
collected 1 item
==DISCOVERED TESTS BEGIN==
{"tests": [{"id": "root/opt/sbin/pytest/efd_dummy_test.py::Test_Dummy::test_pass", "line": 50}], "errors": []}
==DISCOVERED TESTS END==

root/opt/sbin/pytest/efd_dummy_test.py .                                 [100%]

============================== 1 passed in 0.04s ===============================

vscode Result

vscode-python-test-explorer-issue

More Info (2022-03-02)

Even though when running in debug mode where the output says it passed, the tests do not complete. The vscode ui states the tests are still running ("Running tests...") - even a simple test that just asserts true.

So looks like something is waiting indefinitely with Python Test Explorer.

vscode-python-test-explorer-running-tests

vscode-python-test-explorer-running-tests-2

NOTE: running with the same tests with the vscode native python test framework is ok. I do get green ticks (check marks).

vscode-python-test-passed-1

vscode-python-test-passed-2

BrendanSimon commented 2 years ago

So I switched branches and things started working with Python Test Explorer. All tests pass now except for 1 (with the same symptoms of greyed out result - not red, not greed).

I have switched back and forth between the prior branch and made sure the vscode settings were the same, and I now get the same partial test results (but everything passes in the native python test explorer).

BrendanSimon commented 2 years ago

SOLVED !!

I noticed that the debug output had references to files stored in /mnt/brendansimon/...

My home directory was on a separate (virtual) disk, mouted to /mnt/brendansimon and then symlinked from /home/brendansimon.

The symlink was causing an issue with my build so I removed that mounted directly to /home/brendansimon via /etc/fstab, and the build works.

Seems there are some references to ../../../../../mnt/brendansimon/....../pytest/xxx_test.py in the debug output, and ultimately the pytest cache, which seems to cause havoc with Python Test Explorer (in run mode only - debug seems ok).

Anyway, removing the cache directory fixed things so that Python Test Explorer now works as expected.

rm -rf .pytest_cache

Sorry for all the noise :-/

BrendanSimon commented 2 years ago

Mind you, removing the cache files/directories doesn't explain why all tests passed with native python test explorer but failed with Python Test Adapter (at least it's not clear to me).

vipwp commented 2 years ago

SOLVED !!

I noticed that the debug output had references to files stored in /mnt/brendansimon/...

My home directory was on a separate (virtual) disk, mouted to /mnt/brendansimon and then symlinked from /home/brendansimon.

The symlink was causing an issue with my build so I removed that mounted directly to /home/brendansimon via /etc/fstab, and the build works.

Seems there are some references to ../../../../../mnt/brendansimon/....../pytest/xxx_test.py in the debug output, and ultimately the pytest cache, which seems to cause havoc with Python Test Explorer (in run mode only - debug seems ok).

Anyway, removing the cache directory fixed things so that Python Test Explorer now works as expected.

rm -rf .pytest_cache

Sorry for all the noise :-/

Thanks, it works~~