From 606b959d190fbca85f81a464788d1df01e145d80 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Tue, 31 Dec 2019 17:49:15 +0800 Subject: [PATCH] fix: unittest for jsonschema checker --- httprunner/loader/__init__.py | 2 +- httprunner/loader/check.py | 2 -- tests/test_loader/test_load.py | 11 ++++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/httprunner/loader/__init__.py b/httprunner/loader/__init__.py index 8c6320b2..4b6ecccd 100644 --- a/httprunner/loader/__init__.py +++ b/httprunner/loader/__init__.py @@ -1,7 +1,7 @@ """ HttpRunner loader -- check: validate testcase data structure with JSON schema (TODO) +- check: validate api/testcase/testsuite data structure with JSON schema - locate: locate debugtalk.py, make it's dir as project root path - load: load testcase files and relevant data, including debugtalk.py, .env, yaml/json api/testcases, csv, etc. - buildup: assemble loaded content to httprunner testcase/testsuite data structure diff --git a/httprunner/loader/check.py b/httprunner/loader/check.py index 6316e242..c73156b6 100644 --- a/httprunner/loader/check.py +++ b/httprunner/loader/check.py @@ -188,8 +188,6 @@ def is_testcase_path(path): if not os.path.exists(path): return False - # TODO: check file format if valid - return True diff --git a/tests/test_loader/test_load.py b/tests/test_loader/test_load.py index b394032e..4a2e0f91 100644 --- a/tests/test_loader/test_load.py +++ b/tests/test_loader/test_load.py @@ -3,6 +3,7 @@ import unittest from httprunner import exceptions from httprunner.loader import load +from httprunner.loader.buildup import load_test_file class TestFileLoader(unittest.TestCase): @@ -14,7 +15,7 @@ class TestFileLoader(unittest.TestCase): f.write("") with self.assertRaises(exceptions.FileFormatError): - load._load_yaml_file(yaml_tmp_file) + load_test_file(yaml_tmp_file) os.remove(yaml_tmp_file) @@ -23,7 +24,7 @@ class TestFileLoader(unittest.TestCase): f.write("abc") with self.assertRaises(exceptions.FileFormatError): - load._load_yaml_file(yaml_tmp_file) + load_test_file(yaml_tmp_file) os.remove(yaml_tmp_file) @@ -34,7 +35,7 @@ class TestFileLoader(unittest.TestCase): f.write("") with self.assertRaises(exceptions.FileFormatError): - load._load_json_file(json_tmp_file) + load_test_file(json_tmp_file) os.remove(json_tmp_file) @@ -43,7 +44,7 @@ class TestFileLoader(unittest.TestCase): f.write("{}") with self.assertRaises(exceptions.FileFormatError): - load._load_json_file(json_tmp_file) + load_test_file(json_tmp_file) os.remove(json_tmp_file) @@ -52,7 +53,7 @@ class TestFileLoader(unittest.TestCase): f.write("abc") with self.assertRaises(exceptions.FileFormatError): - load._load_json_file(json_tmp_file) + load_test_file(json_tmp_file) os.remove(json_tmp_file)