-
Notifications
You must be signed in to change notification settings - Fork 304
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
Add copy of Python Extension API service for functional tests #33
Merged
DonJayamanne
merged 1 commit into
microsoft:main
from
DonJayamanne:interpreterServiceForFuncTests
Sep 14, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -560,12 +560,6 @@ suite('DataScience notebook tests', () => { | |
// Rewire our data we use to search for processes | ||
@injectable() | ||
class EmptyInterpreterService implements IInterpreterService { | ||
public get hasInterpreters(): Promise<boolean> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant code |
||
return Promise.resolve(true); | ||
} | ||
public onDidChangeInterpreterConfiguration(): Disposable { | ||
return { dispose: noop }; | ||
} | ||
public onDidChangeInterpreter( | ||
_listener: (e: void) => any, | ||
_thisArgs?: any, | ||
|
@@ -577,27 +571,12 @@ suite('DataScience notebook tests', () => { | |
public getInterpreters(_resource?: Uri): Promise<PythonEnvironment[]> { | ||
return Promise.resolve([]); | ||
} | ||
public autoSetInterpreter(): Promise<void> { | ||
throw new Error('Method not implemented'); | ||
} | ||
public getActiveInterpreter(_resource?: Uri): Promise<PythonEnvironment | undefined> { | ||
return Promise.resolve(undefined); | ||
} | ||
public getInterpreterDetails(_pythonPath: string, _resoure?: Uri): Promise<PythonEnvironment> { | ||
throw new Error('Method not implemented'); | ||
} | ||
public refresh(_resource: Uri): Promise<void> { | ||
throw new Error('Method not implemented'); | ||
} | ||
public initialize(): void { | ||
throw new Error('Method not implemented'); | ||
} | ||
public getDisplayName(_interpreter: Partial<PythonEnvironment>): Promise<string> { | ||
throw new Error('Method not implemented'); | ||
} | ||
public shouldAutoSetInterpreter(): Promise<boolean> { | ||
throw new Error('Method not implemented'); | ||
} | ||
} | ||
ioc.serviceManager.rebind<IInterpreterService>(IInterpreterService, EmptyInterpreterService); | ||
await createNotebook(undefined, undefined, true); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { injectable } from 'inversify'; | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { getActivatedEnvVariables } from '.'; | ||
import { Resource } from '../../client/common/types'; | ||
import { IEnvironmentActivationService } from '../../client/interpreter/activation/types'; | ||
import { PythonEnvironment } from '../../client/pythonEnvironments/info'; | ||
|
||
@injectable() | ||
export class EnvironmentActivationService implements IEnvironmentActivationService { | ||
public getActivatedEnvironmentVariables( | ||
_resource: Resource, | ||
interpreter?: PythonEnvironment, | ||
_allowExceptions?: boolean | ||
): Promise<NodeJS.ProcessEnv | undefined> { | ||
return getActivatedEnvVariables(interpreter?.path || process.env.CI_PYTHON_PATH || 'python'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { inject, injectable } from 'inversify'; | ||
import { Resource } from '../../client/common/types'; | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { IInterpreterQuickPickItem, IInterpreterSelector } from '../../client/interpreter/configuration/types'; | ||
import { IInterpreterService } from '../../client/interpreter/contracts'; | ||
|
||
@injectable() | ||
export class InterpreterSelector implements IInterpreterSelector { | ||
constructor(@inject(IInterpreterService) private readonly interpreterService: IInterpreterService) {} | ||
|
||
public async getSuggestions(resource: Resource): Promise<IInterpreterQuickPickItem[]> { | ||
const interpreters = await this.interpreterService.getInterpreters(resource); | ||
return interpreters.map((item) => ({ | ||
label: item.displayName || item.path, | ||
description: item.displayName || item.path, | ||
detail: item.displayName || item.path, | ||
path: item.path, | ||
interpreter: item | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { injectable } from 'inversify'; | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { IWindowsStoreInterpreter } from '../../client/interpreter/locators/types'; | ||
|
||
@injectable() | ||
export class WindowsStoreInterpreter implements IWindowsStoreInterpreter { | ||
/** | ||
* Whether this is a Windows Store/App Interpreter. | ||
* | ||
* @param {string} pythonPath | ||
* @returns {boolean} | ||
* @memberof WindowsStoreInterpreter | ||
*/ | ||
public async isWindowsStoreInterpreter(pythonPath: string): Promise<boolean> { | ||
const pythonPathToCompare = pythonPath.toUpperCase().replace(/\//g, '\\'); | ||
return ( | ||
pythonPathToCompare.includes('\\Microsoft\\WindowsApps\\'.toUpperCase()) || | ||
pythonPathToCompare.includes('\\Program Files\\WindowsApps\\'.toUpperCase()) || | ||
pythonPathToCompare.includes('\\Microsoft\\WindowsApps\\PythonSoftwareFoundation'.toUpperCase()) | ||
); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in tests.