Skip to content
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 support for Hatch environments #22779

Merged
merged 16 commits into from
Mar 15, 2024
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"--ui=tdd",
"--recursive",
"--colors",
//"--grep", "<suite name>",
flying-sheep marked this conversation as resolved.
Show resolved Hide resolved
"--grep", "Hatch Locator",
"--timeout=300000"
],
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,32 @@ suite('Hatch Locator', () => {
getOSType.returns(platformUtils.OSType.Linux);
flying-sheep marked this conversation as resolved.
Show resolved Hide resolved
});

test('project with only the default env', async () => {
interface TestArgs {
osType?: platformUtils.OSType;
pythonBin?: string;
}

const testProj1 = async ({ osType, pythonBin = 'bin/python' }: TestArgs = {}) => {
if (osType) {
getOSType.returns(osType);
}

locator = new HatchLocator(projectDirs.project1);
exec.callsFake(makeExecHandler(venvDirs.project1, { hatchPath: 'hatch', cwd: projectDirs.project1 }));

const iterator = locator.iterEnvs();
const actualEnvs = await getEnvs(iterator);

const expectedEnvs = [
createBasicEnv(PythonEnvKind.Hatch, path.join(venvDirs.project1.default, 'bin/python')),
];
const expectedEnvs = [createBasicEnv(PythonEnvKind.Hatch, path.join(venvDirs.project1.default, pythonBin))];
assertBasicEnvsEqual(actualEnvs, expectedEnvs);
});
};

test('project with only the default env', () => testProj1());
test('project with only the default env on Windows', () =>
testProj1({
osType: platformUtils.OSType.Windows,
pythonBin: 'Scripts/python.exe',
}));

test('project with multiple defined envs', async () => {
locator = new HatchLocator(projectDirs.project2);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Not real python exe
Loading