mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
feat: add pytest sub-command to run pytest scripts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package pytest
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func RunPytest(args []string) error {
|
||||
cmd := exec.Command("pytest", args...)
|
||||
log.Info().Str("cmd", cmd.String()).Msg("run pytest")
|
||||
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "pytest running failed")
|
||||
}
|
||||
out := strings.TrimSpace(string(output))
|
||||
println(out)
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user