forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserviceRegistry.ts
More file actions
39 lines (32 loc) · 1.63 KB
/
serviceRegistry.ts
File metadata and controls
39 lines (32 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { Uri } from 'vscode';
import { IProcessServiceFactory } from '../../client/common/process/types';
import { IInterpreterHelper } from '../../client/interpreter/contracts';
import { InterpreterHelper } from '../../client/interpreter/helpers';
import { TestsHelper } from '../../client/testing/common/testUtils';
import { ITestsHelper, IUnitTestSocketServer } from '../../client/testing/common/types';
import { getPythonSemVer } from '../common';
import { IocContainer } from '../serviceRegistry';
import { MockUnitTestSocketServer } from './mocks';
export class UnitTestIocContainer extends IocContainer {
public async getPythonMajorVersion(resource: Uri): Promise<number> {
const procServiceFactory = this.serviceContainer.get<IProcessServiceFactory>(IProcessServiceFactory);
const procService = await procServiceFactory.create(resource);
const pythonVersion = await getPythonSemVer(procService);
if (pythonVersion) {
return pythonVersion.major;
}
return -1; // log warning already issued by underlying functions...
}
public registerTestsHelper(): void {
this.serviceManager.addSingleton<ITestsHelper>(ITestsHelper, TestsHelper);
}
public registerInterpreterStorageTypes(): void {
this.serviceManager.add<IInterpreterHelper>(IInterpreterHelper, InterpreterHelper);
}
public registerMockUnitTestSocketServer(): void {
this.serviceManager.addSingleton<IUnitTestSocketServer>(IUnitTestSocketServer, MockUnitTestSocketServer);
}
}