1
0
Fork 0
mirror of https://code.forgejo.org/actions/setup-python synced 2025-06-09 12:52:20 +02:00

feature: add version parsing from Pipfile

This commit is contained in:
Aramís Segovia 2025-03-26 22:46:53 -04:00
parent 5db1cf9a59
commit c44ab2e287
5 changed files with 222 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import {
getVersionInputFromFile,
getVersionsInputFromPlainFile,
getVersionInputFromTomlFile,
getVersionInputFromPipfileFile,
getNextPageUrl,
isGhes,
IS_WINDOWS,
@ -244,6 +245,44 @@ describe('Version from file test', () => {
expect(_fn(toolVersionFilePath)).toEqual(['3.14t-dev']);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13';
const pythonVersionFileContent = `[requires]\npython_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_full_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13.0';
const pythonVersionFileContent = `[requires]\npython_full_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Pipfile undefined version',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersionFileContent = ``;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([]);
}
);
});
describe('getNextPageUrl', () => {