Skip to content

Commit 92d2d85

Browse files
author
Kartik Raj
authored
Fix test failures due to linting (#20617)
Fixes #20612
1 parent d245a90 commit 92d2d85

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed

pythonFiles/testing_tools/adapter/info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def __init__(self, *args, **kwargs):
2727

2828

2929
class ParentInfo(namedtuple("ParentInfo", "id kind name root relpath parentid")):
30-
3130
KINDS = ("folder", "file", "suite", "function", "subtest")
3231

3332
def __new__(cls, id, kind, name, root=None, relpath=None, parentid=None):

pythonFiles/testing_tools/adapter/pytest/_discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99

10-
from .. import util, discovery
10+
from .. import discovery, util
1111
from ._pytest_item import parse_item
1212

1313

@@ -26,7 +26,7 @@ def discover(
2626
pytestargs = _adjust_pytest_args(pytestargs)
2727
# We use this helper rather than "-pno:terminal" due to possible
2828
# platform-dependent issues.
29-
with (util.hide_stdio() if hidestdio else util.noop_cm()) as stdio:
29+
with util.hide_stdio() if hidestdio else util.noop_cm() as stdio:
3030
ec = _pytest_main(pytestargs, [_plugin])
3131
# See: https://docs.pytest.org/en/latest/usage.html#possible-exit-codes
3232
if ec == 5:

pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def main(self, args, plugins):
4646

4747

4848
class StubPlugin(util.StubProxy):
49-
5049
_started = True
5150

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

6766

6867
class StubDiscoveredTests(util.StubProxy):
69-
7068
NOT_FOUND = object()
7169

7270
def __init__(self, stub=None):
@@ -105,7 +103,6 @@ def __init__(self, name):
105103

106104

107105
class StubPytestItem(util.StubProxy):
108-
109106
_debugging = False
110107
_hasfunc = True
111108

@@ -218,6 +215,7 @@ def normcase(path):
218215

219216
else:
220217
raise NotImplementedError
218+
221219
##########
222220
def _fix_fileid(*args):
223221
return adapter_util.fix_fileid(
@@ -332,7 +330,6 @@ def ret(args, plugins):
332330

333331

334332
class DiscoverTests(unittest.TestCase):
335-
336333
DEFAULT_ARGS = [
337334
"--collect-only",
338335
]

pythonFiles/tests/testing_tools/adapter/test___main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import unittest
55

6-
from ...util import Stub, StubProxy
76
from testing_tools.adapter.__main__ import (
8-
parse_args,
9-
main,
10-
UnsupportedToolError,
117
UnsupportedCommandError,
8+
UnsupportedToolError,
9+
main,
10+
parse_args,
1211
)
1312

13+
from ...util import Stub, StubProxy
14+
1415

1516
class StubTool(StubProxy):
1617
def __init__(self, name, stub=None):
@@ -115,7 +116,6 @@ def test_unsupported_tool(self):
115116

116117

117118
class MainTests(unittest.TestCase):
118-
119119
# TODO: We could use an integration test for pytest.discover().
120120

121121
def test_discover(self):

pythonFiles/tests/testing_tools/adapter/test_discovery.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55

66
import unittest
77

8+
from testing_tools.adapter.discovery import DiscoveredTests, fix_nodeid
9+
from testing_tools.adapter.info import ParentInfo, SingleTestInfo, SingleTestPath
810
from testing_tools.adapter.util import fix_path, fix_relpath
9-
from testing_tools.adapter.info import SingleTestInfo, SingleTestPath, ParentInfo
10-
from testing_tools.adapter.discovery import fix_nodeid, DiscoveredTests
1111

1212

1313
def _fix_nodeid(nodeid):
14-
1514
nodeid = nodeid.replace("\\", "/")
1615
if not nodeid.startswith("./"):
1716
nodeid = "./" + nodeid

pythonFiles/unittestadapter/execution.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class TestOutcomeEnum(str, enum.Enum):
6060

6161

6262
class UnittestTestResult(unittest.TextTestResult):
63-
6463
formatted: Dict[str, Dict[str, str | None]] = dict()
6564

6665
def startTest(self, test: unittest.TestCase):

src/test/linters/lint.multiroot.test.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import { ProductService } from '../../client/common/installer/productService';
1212
import { IProductPathService, IProductService } from '../../client/common/installer/types';
1313
import { IConfigurationService, Product, ProductType } from '../../client/common/types';
1414
import { OSType } from '../../client/common/utils/platform';
15+
import { PythonPathUpdaterService } from '../../client/interpreter/configuration/pythonPathUpdaterService';
16+
import { PythonPathUpdaterServiceFactory } from '../../client/interpreter/configuration/pythonPathUpdaterServiceFactory';
17+
import {
18+
IPythonPathUpdaterServiceManager,
19+
IPythonPathUpdaterServiceFactory,
20+
} from '../../client/interpreter/configuration/types';
21+
import { IActivatedEnvironmentLaunch } from '../../client/interpreter/contracts';
22+
import { ActivatedEnvironmentLaunch } from '../../client/interpreter/virtualEnvs/activatedEnvLaunch';
1523
import { ILinter, ILinterManager } from '../../client/linters/types';
1624
import { isOs } from '../common';
1725
import { TEST_TIMEOUT } from '../constants';
@@ -25,22 +33,22 @@ suite('Multiroot Linting', () => {
2533
const flake8Setting = 'linting.flake8Enabled';
2634

2735
let ioc: UnitTestIocContainer;
28-
suiteSetup(function () {
36+
suiteSetup(async function () {
2937
if (!IS_MULTI_ROOT_TEST) {
3038
this.skip();
3139
}
32-
return initialize();
33-
});
34-
setup(async () => {
40+
await initialize();
3541
await initializeDI();
3642
await initializeTest();
3743
});
38-
suiteTeardown(closeActiveWindows);
39-
teardown(async () => {
40-
await ioc.dispose();
44+
suiteTeardown(async () => {
45+
await ioc?.dispose();
4146
await closeActiveWindows();
4247
PythonSettings.dispose();
4348
});
49+
teardown(async () => {
50+
await closeActiveWindows();
51+
});
4452

4553
async function initializeDI() {
4654
ioc = new UnitTestIocContainer();
@@ -50,6 +58,18 @@ suite('Multiroot Linting', () => {
5058
ioc.registerVariableTypes();
5159
ioc.registerFileSystemTypes();
5260
await ioc.registerMockInterpreterTypes();
61+
ioc.serviceManager.addSingleton<IActivatedEnvironmentLaunch>(
62+
IActivatedEnvironmentLaunch,
63+
ActivatedEnvironmentLaunch,
64+
);
65+
ioc.serviceManager.addSingleton<IPythonPathUpdaterServiceManager>(
66+
IPythonPathUpdaterServiceManager,
67+
PythonPathUpdaterService,
68+
);
69+
ioc.serviceManager.addSingleton<IPythonPathUpdaterServiceFactory>(
70+
IPythonPathUpdaterServiceFactory,
71+
PythonPathUpdaterServiceFactory,
72+
);
5373
ioc.registerInterpreterStorageTypes();
5474
ioc.serviceManager.addSingletonInstance<IProductService>(IProductService, new ProductService());
5575
ioc.serviceManager.addSingleton<IProductPathService>(

0 commit comments

Comments
 (0)