forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockPythonService.ts
More file actions
67 lines (55 loc) · 2.88 KB
/
mockPythonService.ts
File metadata and controls
67 lines (55 loc) · 2.88 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import {
ExecutionResult,
InterpreterInfomation,
IPythonExecutionService,
ObservableExecutionResult,
SpawnOptions
} from '../../client/common/process/types';
import { PythonInterpreter } from '../../client/interpreter/contracts';
import { MockProcessService } from './mockProcessService';
export class MockPythonService implements IPythonExecutionService {
private interpreter: PythonInterpreter;
private procService: MockProcessService = new MockProcessService();
constructor(interpreter: PythonInterpreter) {
this.interpreter = interpreter;
}
public getInterpreterInformation(): Promise<InterpreterInfomation> {
return Promise.resolve(this.interpreter);
}
public getExecutablePath(): Promise<string> {
return Promise.resolve(this.interpreter.path);
}
public isModuleInstalled(_moduleName: string): Promise<boolean> {
return Promise.resolve(false);
}
public execObservable(args: string[], options: SpawnOptions): ObservableExecutionResult<string> {
return this.procService.execObservable(this.interpreter.path, args, options);
}
public execModuleObservable(moduleName: string, args: string[], options: SpawnOptions): ObservableExecutionResult<string> {
return this.procService.execObservable(this.interpreter.path, ['-m', moduleName, ...args], options);
}
public exec(args: string[], options: SpawnOptions): Promise<ExecutionResult<string>> {
return this.procService.exec(this.interpreter.path, args, options);
}
public execModule(moduleName: string, args: string[], options: SpawnOptions): Promise<ExecutionResult<string>> {
return this.procService.exec(this.interpreter.path, ['-m', moduleName, ...args], options);
}
public addExecResult(args: (string | RegExp)[], result: () => Promise<ExecutionResult<string>>) {
this.procService.addExecResult(this.interpreter.path, args, result);
}
public addExecModuleResult(moduleName: string, args: (string | RegExp)[], result: () => Promise<ExecutionResult<string>>) {
this.procService.addExecResult(this.interpreter.path, ['-m', moduleName, ...args], result);
}
public addExecObservableResult(args: (string | RegExp)[], result: () => ObservableExecutionResult<string>) {
this.procService.addExecObservableResult(this.interpreter.path, args, result);
}
public addExecModuleObservableResult(moduleName: string, args: (string | RegExp)[], result: () => ObservableExecutionResult<string>) {
this.procService.addExecObservableResult(this.interpreter.path, ['-m', moduleName, ...args], result);
}
public setDelay(timeout: number | undefined) {
this.procService.setDelay(timeout);
}
}