mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
rename test folder to tests
This commit is contained in:
@@ -3,7 +3,7 @@ import time
|
||||
import unittest
|
||||
|
||||
from ate import utils
|
||||
from test import api_server
|
||||
from tests import api_server
|
||||
|
||||
|
||||
class ApiServerUnittest(unittest.TestCase):
|
||||
@@ -34,7 +34,7 @@ bind_lambda_functions_with_import:
|
||||
bind_module_functions:
|
||||
function_binds:
|
||||
import_module_functions:
|
||||
- test.data.custom_functions
|
||||
- tests.data.custom_functions
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- random: ${gen_random_string(5)}
|
||||
@@ -1,7 +1,7 @@
|
||||
- config:
|
||||
name: "create user testsets."
|
||||
import_module_functions:
|
||||
- test.data.custom_functions
|
||||
- tests.data.custom_functions
|
||||
variable_binds:
|
||||
- TOKEN: debugtalk
|
||||
- json: {}
|
||||
@@ -1,6 +1,6 @@
|
||||
import requests
|
||||
import random
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestApiServer(ApiServerUnittest):
|
||||
def setUp(self):
|
||||
@@ -1,7 +1,7 @@
|
||||
import random
|
||||
import requests
|
||||
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
|
||||
class TestApiServerV2(ApiServerUnittest):
|
||||
@@ -1,5 +1,5 @@
|
||||
from ate.client import HttpSession
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestHttpClient(ApiServerUnittest):
|
||||
def setUp(self):
|
||||
@@ -9,7 +9,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.context = Context()
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/demo_binds.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo_binds.yml')
|
||||
self.testcases = utils.load_testcases(testcase_file_path)
|
||||
|
||||
def test_context_register_variables(self):
|
||||
@@ -127,7 +127,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
|
||||
def test_import_module_functions(self):
|
||||
testcase1 = {
|
||||
"import_module_functions": ["test.data.custom_functions"],
|
||||
"import_module_functions": ["tests.data.custom_functions"],
|
||||
"variable_binds": [
|
||||
{"TOKEN": "debugtalk"},
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
@@ -162,7 +162,7 @@ class VariableBindsUnittest(unittest.TestCase):
|
||||
def test_get_parsed_request(self):
|
||||
test_runner = runner.Runner()
|
||||
testcase = {
|
||||
"import_module_functions": ["test.data.custom_functions"],
|
||||
"import_module_functions": ["tests.data.custom_functions"],
|
||||
"variable_binds": [
|
||||
{"TOKEN": "debugtalk"},
|
||||
{"random": "${gen_random_string(5)}"},
|
||||
@@ -1,6 +1,6 @@
|
||||
import requests
|
||||
from ate import response, exception
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestResponse(ApiServerUnittest):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import requests
|
||||
from ate import runner, exception, utils
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestRunner(ApiServerUnittest):
|
||||
|
||||
@@ -14,14 +14,14 @@ class TestRunner(ApiServerUnittest):
|
||||
return requests.delete(url)
|
||||
|
||||
def test_run_single_testcase_yaml_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
testcase = testcases[0]["test"]
|
||||
success, _ = self.test_runner.run_test(testcase)
|
||||
self.assertTrue(success)
|
||||
|
||||
def test_run_single_testcase_json_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.json')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
testcase = testcases[0]["test"]
|
||||
success, _ = self.test_runner.run_test(testcase)
|
||||
@@ -69,28 +69,28 @@ class TestRunner(ApiServerUnittest):
|
||||
)
|
||||
|
||||
def test_run_testset_json_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.json')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertEqual(results, [(True, []), (True, [])])
|
||||
|
||||
def test_run_testsets_json_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.json')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0], [(True, []), (True, [])])
|
||||
|
||||
def test_run_testset_yaml_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
self.assertEqual(results, [(True, []), (True, [])])
|
||||
|
||||
def test_run_testsets_yaml_success(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import requests
|
||||
from ate import runner, exception, utils
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
@@ -17,7 +17,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_single_testcase_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.yml')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.yml')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
testcase = testcases[0]["test"]
|
||||
success, _ = self.test_runner.run_test(testcase)
|
||||
@@ -25,7 +25,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_single_testcase_json(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.json')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.json')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
testcase = testcases[0]["test"]
|
||||
success, _ = self.test_runner.run_test(testcase)
|
||||
@@ -33,7 +33,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_auth_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.yml')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
@@ -41,7 +41,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testsets_auth_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.yml')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
@@ -49,7 +49,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_auth_json(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.json')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.json')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
@@ -57,7 +57,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testsets_auth_json(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_auth_hardcode.json')
|
||||
os.getcwd(), 'tests/data/simple_demo_auth_hardcode.json')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
@@ -65,7 +65,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testcase_template_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/demo_template_separate.yml')
|
||||
os.getcwd(), 'tests/data/demo_template_separate.yml')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
success, _ = self.test_runner.run_test(testcases[0]["test"])
|
||||
self.assertTrue(success)
|
||||
@@ -74,7 +74,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_template_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/demo_template_sets.yml')
|
||||
os.getcwd(), 'tests/data/demo_template_sets.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
@@ -82,7 +82,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testsets_template_yaml(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/demo_template_sets.yml')
|
||||
os.getcwd(), 'tests/data/demo_template_sets.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
@@ -90,7 +90,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testset_template_import_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/demo_import_functions.yml')
|
||||
os.getcwd(), 'tests/data/demo_import_functions.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testset(testsets[0])
|
||||
self.assertEqual(len(results), 2)
|
||||
@@ -98,7 +98,7 @@ class TestRunnerV2(ApiServerUnittest):
|
||||
|
||||
def test_run_testsets_template_import_functions(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/demo_import_functions.yml')
|
||||
os.getcwd(), 'tests/data/demo_import_functions.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
results = self.test_runner.run_testsets(testsets)
|
||||
self.assertEqual(len(results), 1)
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import random
|
||||
import requests
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
from ate import task, utils
|
||||
|
||||
class TestMain(ApiServerUnittest):
|
||||
@@ -14,7 +14,7 @@ class TestMain(ApiServerUnittest):
|
||||
return requests.delete(url)
|
||||
|
||||
def test_create_suite(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testsets = utils.load_testcases_by_path(testcase_file_path)
|
||||
suite = task.create_suite(testsets[0])
|
||||
self.assertEqual(suite.countTestCases(), 2)
|
||||
@@ -22,7 +22,7 @@ class TestMain(ApiServerUnittest):
|
||||
self.assertIsInstance(testcase, task.ApiTestCase)
|
||||
|
||||
def test_create_task(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
task_suite = task.create_task(testcase_file_path)
|
||||
self.assertEqual(task_suite.countTestCases(), 2)
|
||||
for suite in task_suite:
|
||||
@@ -1,18 +1,18 @@
|
||||
import os
|
||||
from ate import utils
|
||||
from ate import exception
|
||||
from test.base import ApiServerUnittest
|
||||
from tests.base import ApiServerUnittest
|
||||
|
||||
class TestUtils(ApiServerUnittest):
|
||||
|
||||
def test_load_testcases_bad_filepath(self):
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'test/data/demo')
|
||||
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo')
|
||||
with self.assertRaises(exception.ParamsError):
|
||||
utils.load_testcases(testcase_file_path)
|
||||
|
||||
def test_load_json_testcases(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||
os.getcwd(), 'tests/data/simple_demo_no_auth.json')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
self.assertEqual(len(testcases), 2)
|
||||
testcase = testcases[0]["test"]
|
||||
@@ -23,7 +23,7 @@ class TestUtils(ApiServerUnittest):
|
||||
|
||||
def test_load_yaml_testcases(self):
|
||||
testcase_file_path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_no_auth.yml')
|
||||
os.getcwd(), 'tests/data/simple_demo_no_auth.yml')
|
||||
testcases = utils.load_testcases(testcase_file_path)
|
||||
self.assertEqual(len(testcases), 2)
|
||||
testcase = testcases[0]["test"]
|
||||
@@ -33,10 +33,10 @@ class TestUtils(ApiServerUnittest):
|
||||
self.assertIn('method', testcase['request'])
|
||||
|
||||
def test_load_foler_files(self):
|
||||
folder = os.path.join(os.getcwd(), 'test')
|
||||
folder = os.path.join(os.getcwd(), 'tests')
|
||||
files = utils.load_foler_files(folder)
|
||||
file1 = os.path.join(os.getcwd(), 'test', 'test_utils.py')
|
||||
file2 = os.path.join(os.getcwd(), 'test', 'data', 'demo_binds.yml')
|
||||
file1 = os.path.join(os.getcwd(), 'tests', 'test_utils.py')
|
||||
file2 = os.path.join(os.getcwd(), 'tests', 'data', 'demo_binds.yml')
|
||||
self.assertIn(file1, files)
|
||||
self.assertIn(file2, files)
|
||||
|
||||
@@ -45,14 +45,14 @@ class TestUtils(ApiServerUnittest):
|
||||
|
||||
# absolute file path
|
||||
path = os.path.join(
|
||||
os.getcwd(), 'test/data/simple_demo_no_auth.json')
|
||||
os.getcwd(), 'tests/data/simple_demo_no_auth.json')
|
||||
testset_list = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list), 1)
|
||||
self.assertEqual(len(testset_list[0]["testcases"]), 2)
|
||||
testsets_list.extend(testset_list)
|
||||
|
||||
# relative file path
|
||||
path = 'test/data/simple_demo_no_auth.yml'
|
||||
path = 'tests/data/simple_demo_no_auth.yml'
|
||||
testset_list = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list), 1)
|
||||
self.assertEqual(len(testset_list[0]["testcases"]), 2)
|
||||
@@ -60,8 +60,8 @@ class TestUtils(ApiServerUnittest):
|
||||
|
||||
# list/set container with file(s)
|
||||
path = [
|
||||
os.path.join(os.getcwd(), 'test/data/simple_demo_no_auth.json'),
|
||||
'test/data/simple_demo_no_auth.yml'
|
||||
os.path.join(os.getcwd(), 'tests/data/simple_demo_no_auth.json'),
|
||||
'tests/data/simple_demo_no_auth.yml'
|
||||
]
|
||||
testset_list = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list), 2)
|
||||
@@ -79,38 +79,38 @@ class TestUtils(ApiServerUnittest):
|
||||
|
||||
def test_load_testcases_by_path_folder(self):
|
||||
# absolute folder path
|
||||
path = os.path.join(os.getcwd(), 'test/data')
|
||||
path = os.path.join(os.getcwd(), 'tests/data')
|
||||
testset_list_1 = utils.load_testcases_by_path(path)
|
||||
self.assertGreater(len(testset_list_1), 6)
|
||||
|
||||
# relative folder path
|
||||
path = 'test/data/'
|
||||
path = 'tests/data/'
|
||||
testset_list_2 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list_1), len(testset_list_2))
|
||||
|
||||
# list/set container with file(s)
|
||||
path = [
|
||||
os.path.join(os.getcwd(), 'test/data'),
|
||||
'test/data/'
|
||||
os.path.join(os.getcwd(), 'tests/data'),
|
||||
'tests/data/'
|
||||
]
|
||||
testset_list_3 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list_3), 2 * len(testset_list_1))
|
||||
|
||||
def test_load_testcases_by_path_not_exist(self):
|
||||
# absolute folder path
|
||||
path = os.path.join(os.getcwd(), 'test/data_not_exist')
|
||||
path = os.path.join(os.getcwd(), 'tests/data_not_exist')
|
||||
testset_list_1 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_1, [])
|
||||
|
||||
# relative folder path
|
||||
path = 'test/data_not_exist'
|
||||
path = 'tests/data_not_exist'
|
||||
testset_list_2 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_2, [])
|
||||
|
||||
# list/set container with file(s)
|
||||
path = [
|
||||
os.path.join(os.getcwd(), 'test/data_not_exist'),
|
||||
'test/data_not_exist/'
|
||||
os.path.join(os.getcwd(), 'tests/data_not_exist'),
|
||||
'tests/data_not_exist/'
|
||||
]
|
||||
testset_list_3 = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(testset_list_3, [])
|
||||
Reference in New Issue
Block a user