mirror of
https://github.com/actions/setup-python.git
synced 2025-06-28 13:43:47 +00:00
Enhance reading from .python-version
This commit is contained in:
parent
8d9ed9ac5c
commit
13399d0718
3 changed files with 48 additions and 11 deletions
|
@ -10,7 +10,7 @@ import {
|
|||
validatePythonVersionFormatForPyPy,
|
||||
isCacheFeatureAvailable,
|
||||
getVersionInputFromFile,
|
||||
getVersionInputFromPlainFile,
|
||||
getVersionsInputFromPlainFile,
|
||||
getVersionInputFromTomlFile,
|
||||
getNextPageUrl,
|
||||
isGhes,
|
||||
|
@ -95,7 +95,7 @@ const tempDir = path.join(
|
|||
);
|
||||
|
||||
describe('Version from file test', () => {
|
||||
it.each([getVersionInputFromPlainFile, getVersionInputFromFile])(
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Version from plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
|
@ -106,6 +106,28 @@ describe('Version from file test', () => {
|
|||
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersionFileContent]);
|
||||
}
|
||||
);
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Versions from multiline plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'python-version.file';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersionFileContent = '3.8\r\n3.7';
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual(['3.8', '3.7']);
|
||||
}
|
||||
);
|
||||
it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])(
|
||||
'Version from complex plain file test',
|
||||
async _fn => {
|
||||
await io.mkdirP(tempDir);
|
||||
const pythonVersionFileName = 'python-version.file';
|
||||
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
|
||||
const pythonVersionFileContent = '3.10/envs/virtualenv\r# 3.9\n3.8\r\n3.7\r\n 3.6 \r\n';
|
||||
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
|
||||
expect(_fn(pythonVersionFilePath)).toEqual(['3.10', '3.8', '3.7', '3.6']);
|
||||
}
|
||||
);
|
||||
it.each([getVersionInputFromTomlFile, getVersionInputFromFile])(
|
||||
'Version from standard pyproject.toml test',
|
||||
async _fn => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue