mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 10:29:39 +08:00
refactor class name: ApiTestCase => TestCase, ApiTestSuite => TestSuite
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
__version__ = '0.9.4'
|
||||
__version__ = '0.9.5'
|
||||
|
||||
from httprunner.task import HttpRunner
|
||||
|
||||
@@ -4,11 +4,11 @@ import unittest
|
||||
from httprunner import exception, logger, runner, testcase, utils
|
||||
|
||||
|
||||
class ApiTestCase(unittest.TestCase):
|
||||
class TestCase(unittest.TestCase):
|
||||
""" create a testcase.
|
||||
"""
|
||||
def __init__(self, test_runner, testcase_dict):
|
||||
super(ApiTestCase, self).__init__()
|
||||
super(TestCase, self).__init__()
|
||||
self.test_runner = test_runner
|
||||
self.testcase_dict = testcase_dict
|
||||
|
||||
@@ -17,7 +17,7 @@ class ApiTestCase(unittest.TestCase):
|
||||
"""
|
||||
self.test_runner._run_test(self.testcase_dict)
|
||||
|
||||
class ApiTestSuite(unittest.TestSuite):
|
||||
class TestSuite(unittest.TestSuite):
|
||||
""" create test suite with a testset, it may include one or several testcases.
|
||||
each suite should initialize a separate Runner() with testset config.
|
||||
@param
|
||||
@@ -46,7 +46,7 @@ class ApiTestSuite(unittest.TestSuite):
|
||||
passed in variables mapping, it will override variables in config block
|
||||
"""
|
||||
def __init__(self, testset, variables_mapping=None, http_client_session=None):
|
||||
super(ApiTestSuite, self).__init__()
|
||||
super(TestSuite, self).__init__()
|
||||
|
||||
self.config_dict = testset.get("config", {})
|
||||
|
||||
@@ -75,11 +75,11 @@ class ApiTestSuite(unittest.TestSuite):
|
||||
testcase_name = self.test_runner.context.eval_content(testcase_dict["name"])
|
||||
testcase_name_with_color = logger.coloring(testcase_name, "yellow")
|
||||
if utils.PYTHON_VERSION == 3:
|
||||
ApiTestCase.runTest.__doc__ = testcase_name_with_color
|
||||
TestCase.runTest.__doc__ = testcase_name_with_color
|
||||
else:
|
||||
ApiTestCase.runTest.__func__.__doc__ = testcase_name_with_color
|
||||
TestCase.runTest.__func__.__doc__ = testcase_name_with_color
|
||||
|
||||
test = ApiTestCase(self.test_runner, testcase_dict)
|
||||
test = TestCase(self.test_runner, testcase_dict)
|
||||
[self.addTest(test) for _ in range(int(testcase_dict.get("times", 1)))]
|
||||
|
||||
@property
|
||||
@@ -88,7 +88,7 @@ class ApiTestSuite(unittest.TestSuite):
|
||||
return self.test_runner.extract_output(output_variables_list)
|
||||
|
||||
class TaskSuite(unittest.TestSuite):
|
||||
""" create test task suite with specified testcase path.
|
||||
""" create task suite with specified testcase path.
|
||||
each task suite may include one or several test suite.
|
||||
"""
|
||||
def __init__(self, path, mapping=None, http_client_session=None):
|
||||
@@ -117,7 +117,7 @@ class TaskSuite(unittest.TestSuite):
|
||||
|
||||
self.suite_list = []
|
||||
for testset in testsets:
|
||||
suite = ApiTestSuite(testset, mapping, http_client_session)
|
||||
suite = TestSuite(testset, mapping, http_client_session)
|
||||
self.addTest(suite)
|
||||
self.suite_list.append(suite)
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ class TestTask(ApiServerUnittest):
|
||||
def test_create_suite(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
testset = load_test_file(testcase_file_path)
|
||||
suite = task.ApiTestSuite(testset)
|
||||
suite = task.TestSuite(testset)
|
||||
self.assertEqual(suite.countTestCases(), 3)
|
||||
for testcase in suite:
|
||||
self.assertIsInstance(testcase, task.ApiTestCase)
|
||||
self.assertIsInstance(testcase, task.TestCase)
|
||||
|
||||
def test_create_task(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_testset_variables.yml')
|
||||
@@ -29,4 +29,4 @@ class TestTask(ApiServerUnittest):
|
||||
self.assertEqual(task_suite.countTestCases(), 3)
|
||||
for suite in task_suite:
|
||||
for testcase in suite:
|
||||
self.assertIsInstance(testcase, task.ApiTestCase)
|
||||
self.assertIsInstance(testcase, task.TestCase)
|
||||
|
||||
Reference in New Issue
Block a user