Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Python Unittest stopped working #24445

Unanswered
xp190 asked this question in Q&A
Nov 14, 2024 · 2 comments · 4 replies
Discussion options

Hello

I have a project which I've been working on for quite a while now.
I have made extensive use of the python unittest plugin which allows you to run and debug tests directly in vscode ui.
With the recent addition of code coverage, it seems my unit tests no longer want to execute.
They still run from command line just fine, but within vscode, all I get is "Finished running tests!", but no actual results show up, as in all the unit tests are still listed with open circles, not red or green as before.
The only thing I have done is update vscode to the latest version, which I have been doing more or less religiously.

I tried to google for this, but all I can find is issues relating to unit test discovery, this is not my problem, all my unittests are discovered, they just won't execute, none of the buttons next to the unit test do anything aside for printing the "Finished running tests!" message along with a timer which is under a second, and no results.

Do I need to update something do to the introduction of code coverage for python unittest?
I'm not sure how I can recreate the unittests to make them work, or where to even start looking to get them working again.

This has been happening in the past two version of vscode.

Some details
System is Windows 10 Enterprise 22H2 x64
vscode is:
Version: 1.95.2 (system setup)
Commit: e8653663e8840adaf45af01eab5c627a5af81807
Date: 2024-11-07T11:07:22.054Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.19045

Python plugin version: v2024.20.0

launch.json has the debug config setup like this, although even executing the tests won't do anything so I'm not sure it matters:
{
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": false
},

If any other details are required, please let me know.

Thank you in advance
xp

You must be logged in to vote

Replies: 2 comments · 4 replies

Comment options

Hi! Are you saying that none of your tests work now or that you can't get coverage working? What should happen is that if you click run with coverage, thats a new experience but it shouldn't interfere with regular debug and run. Can you send an example of the test which you are running and getting no result?

You must be logged in to vote
3 replies
@xp190
Comment options

Hi
As of the introduction of the code coverage feature, none of my tests run anymore.
I just created a sample test, nothing special

file: test_sample.py
`import unittest

class TestSample(unittest.TestCase):
def test_alwaysSucceed(self):
self.assertTrue(True)`

The test is discovered just fine, it shows up, but clicking any of the buttons next to it results in "Finished running tests!" and a timer of 44ms, but no actual outcome, no way to debug it, it seems to not be executing at all, just gets skipped over.
It doesn't matter if I try test itself, or the class, it always does the same thing, maybe the time changes.
The history shows the same, no actual results, just a record of me attempting to run it.

Very confusing, and no idea where to start troubleshooting this issue
Appreciate any help

Thank you
xp

@karthiknadig
Comment options

It might be better if you can share the entire project. Would it be possible to share the repo?

@xp190
Comment options

Unfortunately I cannot share the project, but I did some digging around and found a few things, and I think I figured it out.
I tried reinstalling just about everything, python, extensions, wsl etc etc, problem kept coming back every time.
I did notice that when I launch code from a windows path ie: C:.... then unitests worked, but I didn't want this, so I went into WSL.
I had a symlink setup to my windows Desktop which pointed to /mnt/c/Users../Desktop where my project lived.
I used code . to start up vscode int that directory, and the issue was back.
I cloned the project to a local WSL directory, ie: /home/user/..../ started up vscode with code . and now everything works.
So it seems that between the two versions something has changed in the way mapping of paths from WSL to windows works, or something with symlinks. Either way, everything else works just fine except for this.

To reproduce, create any project on a windows path, but open it through WSL, and try to run python unittest, seems to only affect windows 10 as I tried the same on win11 and it didn't have the issue.

Comment options

Same issue with:
Version: 1.100.0 (user setup)
Commit: 19e0f9e681ecb8e5c09d8784acaa601316ca4571
Date: 2025-05-07T12:48:53.763Z
Electron: 34.5.1
ElectronBuildId: 11369351
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Windows_NT x64 10.0.26100

There is no signal on whether the test succeeds and no gui elements around the tests, and there is no logs about running of the tests from the 'Python' output channel.

You must be logged in to vote
1 reply
@Whatever314
Comment options

It seems that i have solved this: the project i tested is stored on a NTFS partition shared by both windows and WSL. In wsl, I created a soft link to it in wsl's virtual file system and opened the project with vscode from the soft link. Under such scenerio the extension would not work with unittest.🙃 If i avoid soft links in the process, i.e. tell vscode to open the workspace located in /mnt/..., the extension would work just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.