refactor: replace loader

This commit is contained in:
debugtalk
2020-05-15 15:49:50 +08:00
parent 0d2488ce10
commit 3f6482e79f
14 changed files with 147 additions and 1208 deletions

View File

@@ -7,7 +7,7 @@ from loguru import logger
from httprunner import exceptions
from httprunner.exceptions import TestCaseFormatError
from httprunner.new_loader import load_testcase_file, load_folder_files
from httprunner.loader import load_testcase_file, load_folder_files
__TMPL__ = """# NOTICE: Generated By HttpRunner. DO'NOT EDIT!
import unittest
@@ -96,9 +96,10 @@ def init_make_parser(subparsers):
""" make testcases: parse command line options and run commands.
"""
parser = subparsers.add_parser(
"make",
help="Convert YAML/JSON testcases to Python unittests.",
"make", help="Convert YAML/JSON testcases to Python unittests.",
)
parser.add_argument(
"testcase_path", nargs="?", help="Specify YAML/JSON testcase path"
)
parser.add_argument("testcase_path", nargs="?", help="Specify YAML/JSON testcase path")
return parser

View File

@@ -3,13 +3,12 @@ from httprunner.ext.make import make_testcase, main_make
class TestLoader(unittest.TestCase):
def test_make_testcase(self):
path = "examples/postman_echo/request_methods/request_with_variables.yml"
testcase_python_path = make_testcase(path)
self.assertEqual(
testcase_python_path,
"examples/postman_echo/request_methods/request_with_variables_test.py"
"examples/postman_echo/request_methods/request_with_variables_test.py",
)
def test_make_testcase_folder(self):
@@ -17,5 +16,5 @@ class TestLoader(unittest.TestCase):
testcase_python_list = main_make(path)
self.assertIn(
"examples/postman_echo/request_methods/request_with_functions_test.py",
testcase_python_list
testcase_python_list,
)