feat #1342: support specify custom python3 venv

This commit is contained in:
debugtalk
2022-06-13 14:02:36 +08:00
parent f24c453890
commit 182d2fd5d8
35 changed files with 381 additions and 123 deletions

View File

@@ -48,12 +48,7 @@ func convert2GoTestScripts(paths ...string) error {
}
// format pytest scripts with black
python3, err := builtin.EnsurePython3Venv("black")
if err != nil {
return err
}
args := append([]string{"-m", "black"}, pytestPaths...)
return builtin.ExecCommand(python3, args...)
return builtin.ExecPython3Command("black", pytestPaths...)
}
//go:embed testcase.tmpl

View File

@@ -1,13 +1,10 @@
package convert
import (
"fmt"
"github.com/pkg/errors"
"github.com/httprunner/httprunner/v4/hrp"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
)
func NewConverterJSON(converter *TCaseConverter) *ConverterJSON {
@@ -51,7 +48,7 @@ func (c *ConverterJSON) ToYAML() (string, error) {
}
func (c *ConverterJSON) ToGoTest() (string, error) {
//TODO implement me
// TODO implement me
return "", errors.New("convert from json testcase to gotest scripts is not supported yet")
}
@@ -60,13 +57,8 @@ func (c *ConverterJSON) ToPyTest() (string, error) {
}
func (c *ConverterJSON) MakePyTestScript() (string, error) {
httprunner := fmt.Sprintf("httprunner>=%s", version.HttpRunnerMinVersion)
python3, err := builtin.EnsurePython3Venv(httprunner)
if err != nil {
return "", err
}
args := append([]string{"-m", "httprunner", "make"}, c.converter.InputPath)
err = builtin.ExecCommand(python3, args...)
args := append([]string{"make"}, c.converter.InputPath)
err := builtin.ExecPython3Command("httprunner", args...)
if err != nil {
return "", err
}

View File

@@ -1,19 +1,10 @@
package convert
import (
"fmt"
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
"github.com/httprunner/httprunner/v4/hrp/internal/version"
)
func convert2PyTestScripts(paths ...string) error {
httprunner := fmt.Sprintf("httprunner>=%s", version.HttpRunnerMinVersion)
python3, err := builtin.EnsurePython3Venv(httprunner)
if err != nil {
return err
}
args := append([]string{"-m", "httprunner", "make"}, paths...)
return builtin.ExecCommand(python3, args...)
args := append([]string{"make"}, paths...)
return builtin.ExecPython3Command("httprunner", args...)
}