Skip to content

Commit

Permalink
Fix failing virtualenvwrapper Windows unit tests (#14012)
Browse files Browse the repository at this point in the history
* Fix tests
* Typo
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
Co-authored-by: Karthik Nadig <kanadig@microsoft.com>
  • Loading branch information
kimadeline committed Sep 22, 2020
1 parent 352d9a5 commit a531cba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export async function isVirtualenvwrapperEnvironment(interpreterPath:string): Pr
const environmentName = path.basename(path.dirname(path.dirname(interpreterPath)));

let environmentDir = path.join(workonHomeDir, environmentName);
let pathToCheck = interpreterPath;

if (getOSType() === OSType.Windows) {
environmentDir = environmentDir.toUpperCase();
pathToCheck = interpreterPath.toUpperCase();
}

return await pathExists(environmentDir) && interpreterPath.startsWith(`${environmentDir}${path.sep}`);
return await pathExists(environmentDir) && pathToCheck.startsWith(`${environmentDir}${path.sep}`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ suite('Virtualenvwrapper Locator Tests', () => {
pathExistsStub = sinon.stub(fileUtils, 'pathExists');
getDefaultDirStub = sinon.stub(virtualenvwrapperUtils, 'getDefaultVirtualenvwrapperDir');

pathExistsStub.withArgs(path.join(homeDir, envDirectory)).resolves(true);
pathExistsStub.resolves(false);
pathExistsStub.resolves(true);
});

teardown(() => {
Expand All @@ -32,7 +31,7 @@ suite('Virtualenvwrapper Locator Tests', () => {
getDefaultDirStub.restore();
});

test('WORKON_HOME is not set, and the interpreter is is in a subfolder', async () => {
test('WORKON_HOME is not set, and the interpreter is in a subfolder of virtualenvwrapper', async () => {
const interpreter = path.join(homeDir, envDirectory, 'bin', 'python');

getEnvVariableStub.withArgs('WORKON_HOME').returns(undefined);
Expand All @@ -56,7 +55,6 @@ suite('Virtualenvwrapper Locator Tests', () => {
const interpreter = path.join('some', 'path', envDirectory, 'bin', 'python');

getEnvVariableStub.withArgs('WORKON_HOME').returns(workonHomeDirectory);
pathExistsStub.withArgs(path.join(workonHomeDirectory, envDirectory)).resolves(false);

assert.deepStrictEqual(await isVirtualenvwrapperEnvironment(interpreter), false);
});
Expand Down

0 comments on commit a531cba

Please sign in to comment.