parallel tests and short/non-short mode

This commit is contained in:
Denis Bilenko 2025-03-04 16:18:34 +01:00
parent 62f1c36f89
commit cc59dec5f5
1 changed files with 24 additions and 7 deletions

View File

@ -15,7 +15,11 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
var scriptsDir = getPythonScriptsDir() var (
scriptsDir = getPythonScriptsDir()
prebuiltWheel = "testdata/my_test_code-0.0.1-py3-none-any.whl"
emptyZip = "testdata/empty.zip"
)
func getPythonScriptsDir() string { func getPythonScriptsDir() string {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
@ -24,6 +28,23 @@ func getPythonScriptsDir() string {
return "bin" return "bin"
} }
func getPythonVersions() []string {
if testing.Short() {
return []string{
"python3.9",
"python3.12",
}
} else {
return []string{
"python3.9",
"python3.10",
"python3.11",
"python3.12",
"python3.13",
}
}
}
func verifyVersion(t *testing.T, tempDir, wheelPath string) { func verifyVersion(t *testing.T, tempDir, wheelPath string) {
wheelInfo, err := ParseWheelFilename(wheelPath) wheelInfo, err := ParseWheelFilename(wheelPath)
require.NoError(t, err) require.NoError(t, err)
@ -116,9 +137,10 @@ func getWheel(t *testing.T, dir string) string {
} }
func TestPatchWheel(t *testing.T) { func TestPatchWheel(t *testing.T) {
pythonVersions := []string{"python3.9", "python3.10", "python3.11", "python3.12"} pythonVersions := getPythonVersions()
for _, py := range pythonVersions { for _, py := range pythonVersions {
t.Run(py, func(t *testing.T) { t.Run(py, func(t *testing.T) {
t.Parallel()
tempDir := t.TempDir() tempDir := t.TempDir()
projFiles := minimalPythonProject() projFiles := minimalPythonProject()
@ -165,11 +187,6 @@ func TestPatchWheel(t *testing.T) {
} }
} }
var (
prebuiltWheel = "testdata/my_test_code-0.0.1-py3-none-any.whl"
emptyZip = "testdata/empty.zip"
)
func TestPrebuilt(t *testing.T) { func TestPrebuilt(t *testing.T) {
tempDir := t.TempDir() tempDir := t.TempDir()
ctx := context.Background() ctx := context.Background()