refactor: run tests with pytest

This commit is contained in:
debugtalk
2022-04-22 19:28:16 +08:00
parent 752796a9cc
commit 66a0d13c10
12 changed files with 57 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ import (
"github.com/rs/zerolog/log"
"gopkg.in/yaml.v3"
"github.com/httprunner/funplugin/shared"
"github.com/httprunner/httprunner/hrp/internal/json"
)
@@ -76,6 +77,21 @@ func FormatResponse(raw interface{}) interface{} {
return formattedResponse
}
func EnsurePython3Venv(packages ...string) (string, error) {
// create python venv
home, err := os.UserHomeDir()
if err != nil {
return "", errors.Wrap(err, "get user home dir failed")
}
venvDir := filepath.Join(home, ".hrp", "venv")
python3, err := shared.EnsurePython3Venv(venvDir, packages...)
if err != nil {
return "", errors.Wrap(err, "ensure python venv failed")
}
return python3, nil
}
func ExecCommand(cmd *exec.Cmd, cwd string) error {
log.Info().Str("cmd", cmd.String()).Str("cwd", cwd).Msg("exec command")
cmd.Dir = cwd