mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 03:30:01 +08:00
fix unittests
This commit is contained in:
@@ -77,7 +77,7 @@ def type_match(check_value, expect_value):
|
|||||||
def get_type(name):
|
def get_type(name):
|
||||||
if isinstance(name, type):
|
if isinstance(name, type):
|
||||||
return name
|
return name
|
||||||
elif isinstance(name, str, bytes):
|
elif isinstance(name, str):
|
||||||
try:
|
try:
|
||||||
return __builtins__[name]
|
return __builtins__[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ def _load_json_file(json_file):
|
|||||||
with io.open(json_file, encoding='utf-8') as data_file:
|
with io.open(json_file, encoding='utf-8') as data_file:
|
||||||
try:
|
try:
|
||||||
json_content = json.load(data_file)
|
json_content = json.load(data_file)
|
||||||
except exceptions.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
err_msg = f"JSONDecodeError: JSON file format error: {json_file}"
|
err_msg = f"JSONDecodeError: JSON file format error: {json_file}"
|
||||||
logger.error(err_msg)
|
logger.error(err_msg)
|
||||||
raise exceptions.FileFormatError(err_msg)
|
raise exceptions.FileFormatError(err_msg)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import re
|
import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ class ResponseObject(object):
|
|||||||
elif top_query in ["body", "content", "text", "json"]:
|
elif top_query in ["body", "content", "text", "json"]:
|
||||||
try:
|
try:
|
||||||
body = self.json
|
body = self.json
|
||||||
except exceptions.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
body = self.text
|
body = self.text
|
||||||
|
|
||||||
if not sub_query:
|
if not sub_query:
|
||||||
|
|||||||
@@ -470,7 +470,6 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertEqual(summary["details"][1]["stat"]["total"], 1)
|
self.assertEqual(summary["details"][1]["stat"]["total"], 1)
|
||||||
self.assertEqual(summary["details"][2]["stat"]["total"], 1)
|
self.assertEqual(summary["details"][2]["stat"]["total"], 1)
|
||||||
|
|
||||||
|
|
||||||
def test_run_testcase_hardcode(self):
|
def test_run_testcase_hardcode(self):
|
||||||
for testcase_file_path in self.testcase_file_path_list:
|
for testcase_file_path in self.testcase_file_path_list:
|
||||||
summary = self.runner.run(testcase_file_path)
|
summary = self.runner.run(testcase_file_path)
|
||||||
@@ -479,7 +478,6 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertEqual(summary["stat"]["teststeps"]["total"], 3)
|
self.assertEqual(summary["stat"]["teststeps"]["total"], 3)
|
||||||
self.assertEqual(summary["stat"]["teststeps"]["successes"], 3)
|
self.assertEqual(summary["stat"]["teststeps"]["successes"], 3)
|
||||||
|
|
||||||
|
|
||||||
def test_run_testcase_template_variables(self):
|
def test_run_testcase_template_variables(self):
|
||||||
testcase_file_path = os.path.join(
|
testcase_file_path = os.path.join(
|
||||||
os.getcwd(), 'tests/data/demo_testcase_variables.yml')
|
os.getcwd(), 'tests/data/demo_testcase_variables.yml')
|
||||||
|
|||||||
Reference in New Issue
Block a user