diff --git a/pythonFiles/testing_tools/adapter/info.py b/pythonFiles/testing_tools/adapter/info.py index f99ce0b6f9a2..d518a29dd97a 100644 --- a/pythonFiles/testing_tools/adapter/info.py +++ b/pythonFiles/testing_tools/adapter/info.py @@ -27,7 +27,6 @@ def __init__(self, *args, **kwargs): class ParentInfo(namedtuple("ParentInfo", "id kind name root relpath parentid")): - KINDS = ("folder", "file", "suite", "function", "subtest") def __new__(cls, id, kind, name, root=None, relpath=None, parentid=None): diff --git a/pythonFiles/testing_tools/adapter/pytest/_discovery.py b/pythonFiles/testing_tools/adapter/pytest/_discovery.py index 34312dcc1997..4b852ecf81c9 100644 --- a/pythonFiles/testing_tools/adapter/pytest/_discovery.py +++ b/pythonFiles/testing_tools/adapter/pytest/_discovery.py @@ -7,7 +7,7 @@ import pytest -from .. import util, discovery +from .. import discovery, util from ._pytest_item import parse_item @@ -26,7 +26,7 @@ def discover( pytestargs = _adjust_pytest_args(pytestargs) # We use this helper rather than "-pno:terminal" due to possible # platform-dependent issues. - with (util.hide_stdio() if hidestdio else util.noop_cm()) as stdio: + with util.hide_stdio() if hidestdio else util.noop_cm() as stdio: ec = _pytest_main(pytestargs, [_plugin]) # See: https://docs.pytest.org/en/latest/usage.html#possible-exit-codes if ec == 5: diff --git a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py index c3b8a2d679d1..83eeaa1f9062 100644 --- a/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py @@ -46,7 +46,6 @@ def main(self, args, plugins): class StubPlugin(util.StubProxy): - _started = True def __init__(self, stub=None, tests=None): @@ -66,7 +65,6 @@ def func(*args, **kwargs): class StubDiscoveredTests(util.StubProxy): - NOT_FOUND = object() def __init__(self, stub=None): @@ -105,7 +103,6 @@ def __init__(self, name): class StubPytestItem(util.StubProxy): - _debugging = False _hasfunc = True @@ -218,6 +215,7 @@ def normcase(path): else: raise NotImplementedError + ########## def _fix_fileid(*args): return adapter_util.fix_fileid( @@ -332,7 +330,6 @@ def ret(args, plugins): class DiscoverTests(unittest.TestCase): - DEFAULT_ARGS = [ "--collect-only", ] diff --git a/pythonFiles/tests/testing_tools/adapter/test___main__.py b/pythonFiles/tests/testing_tools/adapter/test___main__.py index d0a778c1d024..5ff0ec30c947 100644 --- a/pythonFiles/tests/testing_tools/adapter/test___main__.py +++ b/pythonFiles/tests/testing_tools/adapter/test___main__.py @@ -3,14 +3,15 @@ import unittest -from ...util import Stub, StubProxy from testing_tools.adapter.__main__ import ( - parse_args, - main, - UnsupportedToolError, UnsupportedCommandError, + UnsupportedToolError, + main, + parse_args, ) +from ...util import Stub, StubProxy + class StubTool(StubProxy): def __init__(self, name, stub=None): @@ -115,7 +116,6 @@ def test_unsupported_tool(self): class MainTests(unittest.TestCase): - # TODO: We could use an integration test for pytest.discover(). def test_discover(self): diff --git a/pythonFiles/tests/testing_tools/adapter/test_discovery.py b/pythonFiles/tests/testing_tools/adapter/test_discovery.py index ec3d198b0108..cf3b8fb3139b 100644 --- a/pythonFiles/tests/testing_tools/adapter/test_discovery.py +++ b/pythonFiles/tests/testing_tools/adapter/test_discovery.py @@ -5,13 +5,12 @@ import unittest +from testing_tools.adapter.discovery import DiscoveredTests, fix_nodeid +from testing_tools.adapter.info import ParentInfo, SingleTestInfo, SingleTestPath from testing_tools.adapter.util import fix_path, fix_relpath -from testing_tools.adapter.info import SingleTestInfo, SingleTestPath, ParentInfo -from testing_tools.adapter.discovery import fix_nodeid, DiscoveredTests def _fix_nodeid(nodeid): - nodeid = nodeid.replace("\\", "/") if not nodeid.startswith("./"): nodeid = "./" + nodeid diff --git a/pythonFiles/unittestadapter/execution.py b/pythonFiles/unittestadapter/execution.py index a016ff1af9ec..a926bcdcc09e 100644 --- a/pythonFiles/unittestadapter/execution.py +++ b/pythonFiles/unittestadapter/execution.py @@ -60,7 +60,6 @@ class TestOutcomeEnum(str, enum.Enum): class UnittestTestResult(unittest.TextTestResult): - formatted: Dict[str, Dict[str, str | None]] = dict() def startTest(self, test: unittest.TestCase): diff --git a/src/test/linters/lint.multiroot.test.ts b/src/test/linters/lint.multiroot.test.ts index f1eaa0bdf803..f89ee86c0b42 100644 --- a/src/test/linters/lint.multiroot.test.ts +++ b/src/test/linters/lint.multiroot.test.ts @@ -12,6 +12,14 @@ import { ProductService } from '../../client/common/installer/productService'; import { IProductPathService, IProductService } from '../../client/common/installer/types'; import { IConfigurationService, Product, ProductType } from '../../client/common/types'; import { OSType } from '../../client/common/utils/platform'; +import { PythonPathUpdaterService } from '../../client/interpreter/configuration/pythonPathUpdaterService'; +import { PythonPathUpdaterServiceFactory } from '../../client/interpreter/configuration/pythonPathUpdaterServiceFactory'; +import { + IPythonPathUpdaterServiceManager, + IPythonPathUpdaterServiceFactory, +} from '../../client/interpreter/configuration/types'; +import { IActivatedEnvironmentLaunch } from '../../client/interpreter/contracts'; +import { ActivatedEnvironmentLaunch } from '../../client/interpreter/virtualEnvs/activatedEnvLaunch'; import { ILinter, ILinterManager } from '../../client/linters/types'; import { isOs } from '../common'; import { TEST_TIMEOUT } from '../constants'; @@ -25,22 +33,22 @@ suite('Multiroot Linting', () => { const flake8Setting = 'linting.flake8Enabled'; let ioc: UnitTestIocContainer; - suiteSetup(function () { + suiteSetup(async function () { if (!IS_MULTI_ROOT_TEST) { this.skip(); } - return initialize(); - }); - setup(async () => { + await initialize(); await initializeDI(); await initializeTest(); }); - suiteTeardown(closeActiveWindows); - teardown(async () => { - await ioc.dispose(); + suiteTeardown(async () => { + await ioc?.dispose(); await closeActiveWindows(); PythonSettings.dispose(); }); + teardown(async () => { + await closeActiveWindows(); + }); async function initializeDI() { ioc = new UnitTestIocContainer(); @@ -50,6 +58,18 @@ suite('Multiroot Linting', () => { ioc.registerVariableTypes(); ioc.registerFileSystemTypes(); await ioc.registerMockInterpreterTypes(); + ioc.serviceManager.addSingleton( + IActivatedEnvironmentLaunch, + ActivatedEnvironmentLaunch, + ); + ioc.serviceManager.addSingleton( + IPythonPathUpdaterServiceManager, + PythonPathUpdaterService, + ); + ioc.serviceManager.addSingleton( + IPythonPathUpdaterServiceFactory, + PythonPathUpdaterServiceFactory, + ); ioc.registerInterpreterStorageTypes(); ioc.serviceManager.addSingletonInstance(IProductService, new ProductService()); ioc.serviceManager.addSingleton(