Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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