GeezerVison is showing github.com — Fix test failures due to linting (#20617) · mitchell-as/vscode-python@92d2d85
File treeExpand file treeCollapse file tree Open diff view settings tests/testing_tools/adapter
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: pythonFiles/testing_tools/adapter/info.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -27,7 +27,6 @@ def __init__(self, *args, **kwargs): | 27 | 27 |
| 28 | 28 |
| 29 | 29 | class ParentInfo(namedtuple("ParentInfo", "id kind name root relpath parentid")): | 30 | | - | 31 | 30 | KINDS = ("folder", "file", "suite", "function", "subtest") | 32 | 31 |
| 33 | 32 | def __new__(cls, id, kind, name, root=None, relpath=None, parentid=None): | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/testing_tools/adapter/pytest/_discovery.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 7 | 7 |
| 8 | 8 | import pytest | 9 | 9 |
| 10 | | -from .. import util, discovery | | 10 | +from .. import discovery, util | 11 | 11 | from ._pytest_item import parse_item | 12 | 12 |
| 13 | 13 |
| @@ -26,7 +26,7 @@ def discover( | 26 | 26 | pytestargs = _adjust_pytest_args(pytestargs) | 27 | 27 | # We use this helper rather than "-pno:terminal" due to possible | 28 | 28 | # 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: | 30 | 30 | ec = _pytest_main(pytestargs, [_plugin]) | 31 | 31 | # See: https://docs.pytest.org/en/latest/usage.html#possible-exit-codes | 32 | 32 | if ec == 5: | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/pytest/test_discovery.py +1-4Lines changed: 1 addition & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,6 @@ def main(self, args, plugins): | 46 | 46 |
| 47 | 47 |
| 48 | 48 | class StubPlugin(util.StubProxy): | 49 | | - | 50 | 49 | _started = True | 51 | 50 |
| 52 | 51 | def __init__(self, stub=None, tests=None): | @@ -66,7 +65,6 @@ def func(*args, **kwargs): | 66 | 65 |
| 67 | 66 |
| 68 | 67 | class StubDiscoveredTests(util.StubProxy): | 69 | | - | 70 | 68 | NOT_FOUND = object() | 71 | 69 |
| 72 | 70 | def __init__(self, stub=None): | @@ -105,7 +103,6 @@ def __init__(self, name): | 105 | 103 |
| 106 | 104 |
| 107 | 105 | class StubPytestItem(util.StubProxy): | 108 | | - | 109 | 106 | _debugging = False | 110 | 107 | _hasfunc = True | 111 | 108 |
| @@ -218,6 +215,7 @@ def normcase(path): | 218 | 215 |
| 219 | 216 | else: | 220 | 217 | raise NotImplementedError | | 218 | + | 221 | 219 | ########## | 222 | 220 | def _fix_fileid(*args): | 223 | 221 | return adapter_util.fix_fileid( | @@ -332,7 +330,6 @@ def ret(args, plugins): | 332 | 330 |
| 333 | 331 |
| 334 | 332 | class DiscoverTests(unittest.TestCase): | 335 | | - | 336 | 333 | DEFAULT_ARGS = [ | 337 | 334 | "--collect-only", | 338 | 335 | ] | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/test___main__.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 |
| 4 | 4 | import unittest | 5 | 5 |
| 6 | | -from ...util import Stub, StubProxy | 7 | 6 | from testing_tools.adapter.__main__ import ( | 8 | | - parse_args, | 9 | | - main, | 10 | | - UnsupportedToolError, | 11 | 7 | UnsupportedCommandError, | | 8 | + UnsupportedToolError, | | 9 | + main, | | 10 | + parse_args, | 12 | 11 | ) | 13 | 12 |
| | 13 | +from ...util import Stub, StubProxy | | 14 | + | 14 | 15 |
| 15 | 16 | class StubTool(StubProxy): | 16 | 17 | def __init__(self, name, stub=None): | @@ -115,7 +116,6 @@ def test_unsupported_tool(self): | 115 | 116 |
| 116 | 117 |
| 117 | 118 | class MainTests(unittest.TestCase): | 118 | | - | 119 | 119 | # TODO: We could use an integration test for pytest.discover(). | 120 | 120 |
| 121 | 121 | def test_discover(self): | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/tests/testing_tools/adapter/test_discovery.py +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 5 | 5 |
| 6 | 6 | import unittest | 7 | 7 |
| | 8 | +from testing_tools.adapter.discovery import DiscoveredTests, fix_nodeid | | 9 | +from testing_tools.adapter.info import ParentInfo, SingleTestInfo, SingleTestPath | 8 | 10 | 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 | 11 | 11 |
| 12 | 12 |
| 13 | 13 | def _fix_nodeid(nodeid): | 14 | | - | 15 | 14 | nodeid = nodeid.replace("\\", "/") | 16 | 15 | if not nodeid.startswith("./"): | 17 | 16 | nodeid = "./" + nodeid | |
Collapse file Copy file name to clipboardExpand all lines: pythonFiles/unittestadapter/execution.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,6 @@ class TestOutcomeEnum(str, enum.Enum): | 60 | 60 |
| 61 | 61 |
| 62 | 62 | class UnittestTestResult(unittest.TextTestResult): | 63 | | - | 64 | 63 | formatted: Dict[str, Dict[str, str | None]] = dict() | 65 | 64 |
| 66 | 65 | def startTest(self, test: unittest.TestCase): | |
Collapse file Copy file name to clipboardExpand all lines: src/test/linters/lint.multiroot.test.ts +27-7Lines changed: 27 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,14 @@ import { ProductService } from '../../client/common/installer/productService'; | 12 | 12 | import { IProductPathService, IProductService } from '../../client/common/installer/types'; | 13 | 13 | import { IConfigurationService, Product, ProductType } from '../../client/common/types'; | 14 | 14 | 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'; | 15 | 23 | import { ILinter, ILinterManager } from '../../client/linters/types'; | 16 | 24 | import { isOs } from '../common'; | 17 | 25 | import { TEST_TIMEOUT } from '../constants'; | @@ -25,22 +33,22 @@ suite('Multiroot Linting', () => { | 25 | 33 | const flake8Setting = 'linting.flake8Enabled'; | 26 | 34 |
| 27 | 35 | let ioc: UnitTestIocContainer; | 28 | | - suiteSetup(function () { | | 36 | + suiteSetup(async function () { | 29 | 37 | if (!IS_MULTI_ROOT_TEST) { | 30 | 38 | this.skip(); | 31 | 39 | } | 32 | | - return initialize(); | 33 | | - }); | 34 | | - setup(async () => { | | 40 | + await initialize(); | 35 | 41 | await initializeDI(); | 36 | 42 | await initializeTest(); | 37 | 43 | }); | 38 | | - suiteTeardown(closeActiveWindows); | 39 | | - teardown(async () => { | 40 | | - await ioc.dispose(); | | 44 | + suiteTeardown(async () => { | | 45 | + await ioc?.dispose(); | 41 | 46 | await closeActiveWindows(); | 42 | 47 | PythonSettings.dispose(); | 43 | 48 | }); | | 49 | + teardown(async () => { | | 50 | + await closeActiveWindows(); | | 51 | + }); | 44 | 52 |
| 45 | 53 | async function initializeDI() { | 46 | 54 | ioc = new UnitTestIocContainer(); | @@ -50,6 +58,18 @@ suite('Multiroot Linting', () => { | 50 | 58 | ioc.registerVariableTypes(); | 51 | 59 | ioc.registerFileSystemTypes(); | 52 | 60 | 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 | + ); | 53 | 73 | ioc.registerInterpreterStorageTypes(); | 54 | 74 | ioc.serviceManager.addSingletonInstance<IProductService>(IProductService, new ProductService()); | 55 | 75 | ioc.serviceManager.addSingleton<IProductPathService>( | |
|