Skip to content

Does not work with vscode unittest runner? #1285

@ziesemer

Description

@ziesemer

Describe the bug

When running tests using with the VS Code unittest runner, test failures no longer report properly. Seems to be an issue with the pyfakefs setup intercepting calls from the test runner itself, possibly even outside the scope of a running test?

How To Reproduce

Use the same code as from https://pytest-pyfakefs.readthedocs.io/en/latest/usage.html#patch-using-fake-filesystem-unittest, but with an added assertion at the end to ensure the test fails:

import os
import typing

from pyfakefs.fake_filesystem_unittest import TestCase

class ExampleTestCase(TestCase):
	@typing.override
	def setUp(self):
		self.setUpPyfakefs()

	def test_create_file(self):
		file_path = "/test/file.txt"
		self.assertFalse(os.path.exists(file_path))
		self.fs.create_file(file_path)
		self.assertTrue(os.path.exists(file_path))
		assert(False)

The test result outputs show:

test_create_file (tests.test_pyfakefs.ExampleTestCase.test_create_file) ... FAIL
Error attempting to connect to extension named pipe /run/user/1000/python-test-results-567064382b9f3143b111[vscode-unittest]: [Errno 2] No such file or directory: '/run/user/1000'

And the test UI only shows this test as a skipped test, not a failure.

I've played with this quite a bit, trying to only include or exclude certain paths, changing where the setup happens and is torn down, etc., and I'm not seeming to find a workable solution.

It seems that pyfakefs and https://github.com/microsoft/vscode-python/blob/main/python_files/unittestadapter/pvsc_utils.py are probably not getting along somewhere?

Your environment

Linux-6.12.62+rpt-rpi-2712-aarch64-with-glibc2.41
Python 3.14.3 (main, Feb 8 2026, 03:02:41) [GCC 14.2.0]
pyfakefs 6.1.1
Visual Studio Code 1.1.09.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions