mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
fix: convert postman to pytest
This commit is contained in:
@@ -450,8 +450,8 @@ func ReadFile(path string) ([]byte, error) {
|
|||||||
return file, nil
|
return file, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetOutputNameWithoutExtension(path string) string {
|
func GetFileNameWithoutExtension(path string) string {
|
||||||
base := filepath.Base(path)
|
base := filepath.Base(path)
|
||||||
ext := filepath.Ext(base)
|
ext := filepath.Ext(base)
|
||||||
return base[0:len(base)-len(ext)] + "_test"
|
return base[0 : len(base)-len(ext)]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ type TCaseConverter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *TCaseConverter) genOutputPath(suffix string) string {
|
func (c *TCaseConverter) genOutputPath(suffix string) string {
|
||||||
outFileFullName := builtin.GetOutputNameWithoutExtension(c.SourcePath) + suffix
|
outFileFullName := builtin.GetFileNameWithoutExtension(c.SourcePath) + "_test" + suffix
|
||||||
if c.OutputDir != "" {
|
if c.OutputDir != "" {
|
||||||
return filepath.Join(c.OutputDir, outFileFullName)
|
return filepath.Join(c.OutputDir, outFileFullName)
|
||||||
} else {
|
} else {
|
||||||
@@ -179,8 +179,13 @@ func (c *TCaseConverter) genOutputPath(suffix string) string {
|
|||||||
|
|
||||||
// convert TCase to pytest case
|
// convert TCase to pytest case
|
||||||
func (c *TCaseConverter) ToPyTest() (string, error) {
|
func (c *TCaseConverter) ToPyTest() (string, error) {
|
||||||
args := append([]string{"make"}, c.SourcePath)
|
jsonPath, err := c.ToJSON()
|
||||||
err := builtin.ExecPython3Command("httprunner", args...)
|
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 {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user