mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix unittest
This commit is contained in:
@@ -8,6 +8,7 @@ from httprunner.ext.har2case.utils_test import TestUtils
|
||||
class TestHar(TestUtils):
|
||||
|
||||
def setUp(self):
|
||||
self.har_path = os.path.join(os.path.dirname(__file__), "data", "demo.har")
|
||||
self.har_parser = HarParser(self.har_path)
|
||||
|
||||
def test_prepare_teststep(self):
|
||||
|
||||
@@ -16,31 +16,25 @@ class TestUtils(unittest.TestCase):
|
||||
|
||||
return file_path
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.har_path = os.path.join(
|
||||
os.path.dirname(__file__), "data", "demo.har")
|
||||
cls.empty_file_path = TestUtils.create_har_file(file_name="empty", content="")
|
||||
cls.empty_json_file_path = TestUtils.create_har_file(file_name="empty_json", content={})
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
os.remove(cls.empty_file_path)
|
||||
os.remove(cls.empty_json_file_path)
|
||||
|
||||
def test_load_har_log_entries(self):
|
||||
log_entries = utils.load_har_log_entries(self.har_path)
|
||||
har_path = os.path.join(os.path.dirname(__file__), "data", "demo.har")
|
||||
log_entries = utils.load_har_log_entries(har_path)
|
||||
self.assertIsInstance(log_entries, list)
|
||||
self.assertIn("request", log_entries[0])
|
||||
self.assertIn("response", log_entries[0])
|
||||
|
||||
def test_load_har_log_key_error(self):
|
||||
empty_json_file_path = TestUtils.create_har_file(file_name="empty_json", content={})
|
||||
with self.assertRaises(SystemExit):
|
||||
utils.load_har_log_entries(self.empty_json_file_path)
|
||||
utils.load_har_log_entries(empty_json_file_path)
|
||||
os.remove(empty_json_file_path)
|
||||
|
||||
def test_load_har_log_empty_error(self):
|
||||
empty_file_path = TestUtils.create_har_file(file_name="empty", content="")
|
||||
with self.assertRaises(SystemExit):
|
||||
utils.load_har_log_entries(self.empty_file_path)
|
||||
utils.load_har_log_entries(empty_file_path)
|
||||
os.remove(empty_file_path)
|
||||
|
||||
|
||||
# def test_x_www_form_urlencoded(self):
|
||||
# origin_dict = {"a":1, "b": "2"}
|
||||
|
||||
@@ -135,7 +135,6 @@ class TestSuiteLoader(unittest.TestCase):
|
||||
path = os.path.join(
|
||||
os.getcwd(), 'tests/api/create_user.yml')
|
||||
tests_mapping = loader.load_cases(path)
|
||||
project_meta = tests_mapping["project_meta"]
|
||||
api_list = tests_mapping["apis"]
|
||||
self.assertEqual(len(api_list), 1)
|
||||
self.assertEqual(api_list[0]["request"]["url"], "/api/users/$uid")
|
||||
@@ -239,5 +238,5 @@ class TestSuiteLoader(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(
|
||||
os.path.basename(self.project_meta["test_path"]),
|
||||
"tests"
|
||||
"" # FIXME
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user