Skip to content

Fix test failures due to linting #20617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pythonFiles/testing_tools/adapter/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions pythonFiles/testing_tools/adapter/pytest/_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

from .. import util, discovery
from .. import discovery, util
from ._pytest_item import parse_item


Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def main(self, args, plugins):


class StubPlugin(util.StubProxy):

_started = True

def __init__(self, stub=None, tests=None):
Expand All @@ -66,7 +65,6 @@ def func(*args, **kwargs):


class StubDiscoveredTests(util.StubProxy):

NOT_FOUND = object()

def __init__(self, stub=None):
Expand Down Expand Up @@ -105,7 +103,6 @@ def __init__(self, name):


class StubPytestItem(util.StubProxy):

_debugging = False
_hasfunc = True

Expand Down Expand Up @@ -218,6 +215,7 @@ def normcase(path):

else:
raise NotImplementedError

##########
def _fix_fileid(*args):
return adapter_util.fix_fileid(
Expand Down Expand Up @@ -332,7 +330,6 @@ def ret(args, plugins):


class DiscoverTests(unittest.TestCase):

DEFAULT_ARGS = [
"--collect-only",
]
Expand Down
10 changes: 5 additions & 5 deletions pythonFiles/tests/testing_tools/adapter/test___main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 2 additions & 3 deletions pythonFiles/tests/testing_tools/adapter/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pythonFiles/unittestadapter/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
34 changes: 27 additions & 7 deletions src/test/linters/lint.multiroot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -50,6 +58,18 @@ suite('Multiroot Linting', () => {
ioc.registerVariableTypes();
ioc.registerFileSystemTypes();
await ioc.registerMockInterpreterTypes();
ioc.serviceManager.addSingleton<IActivatedEnvironmentLaunch>(
IActivatedEnvironmentLaunch,
ActivatedEnvironmentLaunch,
);
ioc.serviceManager.addSingleton<IPythonPathUpdaterServiceManager>(
IPythonPathUpdaterServiceManager,
PythonPathUpdaterService,
);
ioc.serviceManager.addSingleton<IPythonPathUpdaterServiceFactory>(
IPythonPathUpdaterServiceFactory,
PythonPathUpdaterServiceFactory,
);
ioc.registerInterpreterStorageTypes();
ioc.serviceManager.addSingletonInstance<IProductService>(IProductService, new ProductService());
ioc.serviceManager.addSingleton<IProductPathService>(
Expand Down