mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-17 02:57:35 +08:00
fix: compatibility with --save-tests
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from httprunner import compat, exceptions
|
||||
@@ -141,20 +142,38 @@ class TestCompat(unittest.TestCase):
|
||||
)
|
||||
|
||||
def test_ensure_cli_args(self):
|
||||
args1 = ["/path/to/testcase.yml", "--failfast"]
|
||||
self.assertEqual(compat.ensure_cli_args(args1), ["/path/to/testcase.yml"])
|
||||
args1 = ["examples/postman_echo/request_methods/hardcode.yml", "--failfast"]
|
||||
self.assertEqual(
|
||||
compat.ensure_cli_args(args1),
|
||||
["examples/postman_echo/request_methods/hardcode.yml"],
|
||||
)
|
||||
|
||||
args2 = ["/path/to/testcase.yml", "--save-tests"]
|
||||
self.assertEqual(compat.ensure_cli_args(args2), ["/path/to/testcase.yml"])
|
||||
args2 = ["examples/postman_echo/request_methods/hardcode.yml", "--save-tests"]
|
||||
self.assertEqual(
|
||||
compat.ensure_cli_args(args2),
|
||||
["examples/postman_echo/request_methods/hardcode.yml"],
|
||||
)
|
||||
self.assertTrue(
|
||||
os.path.isfile("examples/postman_echo/request_methods/conftest.py")
|
||||
)
|
||||
|
||||
args3 = ["/path/to/testcase.yml", "--report-file", "report.html"]
|
||||
args3 = [
|
||||
"examples/postman_echo/request_methods/hardcode.yml",
|
||||
"--report-file",
|
||||
"report.html",
|
||||
]
|
||||
self.assertEqual(
|
||||
compat.ensure_cli_args(args3),
|
||||
["/path/to/testcase.yml", "--html", "report.html", "--self-contained-html"],
|
||||
[
|
||||
"examples/postman_echo/request_methods/hardcode.yml",
|
||||
"--html",
|
||||
"report.html",
|
||||
"--self-contained-html",
|
||||
],
|
||||
)
|
||||
|
||||
args4 = [
|
||||
"/path/to/testcase.yml",
|
||||
"examples/postman_echo/request_methods/hardcode.yml",
|
||||
"--failfast",
|
||||
"--save-tests",
|
||||
"--report-file",
|
||||
@@ -162,5 +181,10 @@ class TestCompat(unittest.TestCase):
|
||||
]
|
||||
self.assertEqual(
|
||||
compat.ensure_cli_args(args4),
|
||||
["/path/to/testcase.yml", "--html", "report.html", "--self-contained-html"],
|
||||
[
|
||||
"examples/postman_echo/request_methods/hardcode.yml",
|
||||
"--html",
|
||||
"report.html",
|
||||
"--self-contained-html",
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user