forked from DonJayamanne/pythonVSCode
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify interpreter filter (#12792)
- Loading branch information
1 parent
c2cda3d
commit 37c7bef
Showing
8 changed files
with
89 additions
and
35 deletions.
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
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
58 changes: 58 additions & 0 deletions
58
src/test/pythonEnvironments/discovery/locators/interpreterFilter.unit.test.ts
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,58 @@ | ||
import { expect } from 'chai'; | ||
import { isHiddenInterpreter } from '../../../../client/pythonEnvironments/discovery/locators/services/interpreterFilter'; | ||
import { InterpreterType, PythonInterpreter } from '../../../../client/pythonEnvironments/info'; | ||
|
||
// tslint:disable:no-unused-expression | ||
|
||
suite('Interpreters - Filter', () => { | ||
const doNotHideThesePaths = [ | ||
'python', | ||
'python.exe', | ||
'python2', | ||
'python2.exe', | ||
'python38', | ||
'python3.8.exe', | ||
'C:\\Users\\SomeUser\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe', | ||
'%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe', | ||
'%LOCALAPPDATA%\\Microsoft\\WindowsApps\\python.exe' | ||
]; | ||
const hideThesePaths = [ | ||
'%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe', | ||
'C:\\Users\\SomeUser\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe', | ||
'%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation\\python.exe', | ||
'C:\\Users\\SomeUser\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation\\python.exe', | ||
'%LOCALAPPDATA%\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe', | ||
'%LOCALAPPDATA%\\Microsoft\\WindowsApps\\PythonSoftwareFoundation\\python.exe', | ||
'C:\\Program Files\\WindowsApps\\python.exe', | ||
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe', | ||
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation\\python.exe' | ||
]; | ||
|
||
function getInterpreterFromPath(interpreterPath: string): PythonInterpreter { | ||
return { | ||
path: interpreterPath, | ||
sysVersion: '', | ||
sysPrefix: '', | ||
architecture: 1, | ||
companyDisplayName: '', | ||
displayName: 'python', | ||
type: InterpreterType.WindowsStore, | ||
envName: '', | ||
envPath: '', | ||
cachedEntry: false | ||
}; | ||
} | ||
|
||
doNotHideThesePaths.forEach((interpreterPath) => { | ||
test(`Interpreter path should NOT be hidden - ${interpreterPath}`, () => { | ||
const interpreter: PythonInterpreter = getInterpreterFromPath(interpreterPath); | ||
expect(isHiddenInterpreter(interpreter), `${interpreterPath} should NOT be treated as hidden.`).to.be.false; | ||
}); | ||
}); | ||
hideThesePaths.forEach((interpreterPath) => { | ||
test(`Interpreter path should be hidden - ${interpreterPath}`, () => { | ||
const interpreter: PythonInterpreter = getInterpreterFromPath(interpreterPath); | ||
expect(isHiddenInterpreter(interpreter), `${interpreterPath} should be treated as hidden.`).to.be.true; | ||
}); | ||
}); | ||
}); |
File renamed without changes.