fix: convert postman to pytest

This commit is contained in:
debugtalk
2022-06-27 21:28:09 +08:00
parent ea7607868f
commit 0a73f17e2b
2 changed files with 10 additions and 5 deletions

View File

@@ -450,8 +450,8 @@ func ReadFile(path string) ([]byte, error) {
return file, nil
}
func GetOutputNameWithoutExtension(path string) string {
func GetFileNameWithoutExtension(path string) string {
base := filepath.Base(path)
ext := filepath.Ext(base)
return base[0:len(base)-len(ext)] + "_test"
return base[0 : len(base)-len(ext)]
}

View File

@@ -168,7 +168,7 @@ type TCaseConverter struct {
}
func (c *TCaseConverter) genOutputPath(suffix string) string {
outFileFullName := builtin.GetOutputNameWithoutExtension(c.SourcePath) + suffix
outFileFullName := builtin.GetFileNameWithoutExtension(c.SourcePath) + "_test" + suffix
if c.OutputDir != "" {
return filepath.Join(c.OutputDir, outFileFullName)
} else {
@@ -179,8 +179,13 @@ func (c *TCaseConverter) genOutputPath(suffix string) string {
// convert TCase to pytest case
func (c *TCaseConverter) ToPyTest() (string, error) {
args := append([]string{"make"}, c.SourcePath)
err := builtin.ExecPython3Command("httprunner", args...)
jsonPath, err := c.ToJSON()
if err != nil {
return "", errors.Wrap(err, "convert to JSON case failed")
}
args := append([]string{"make"}, jsonPath)
err = builtin.ExecPython3Command("httprunner", args...)
if err != nil {
return "", err
}