mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-22 08:50:13 +08:00
add testcase content check
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ast
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
@@ -326,6 +327,21 @@ def substitute_variables_with_mapping(content, mapping):
|
||||
|
||||
return content
|
||||
|
||||
def check_format(file_path, content):
|
||||
""" check testcase format if valid
|
||||
"""
|
||||
if not content:
|
||||
# testcase file content is empty
|
||||
err_msg = "Testcase file content is empty: {}".format(file_path)
|
||||
logging.error(err_msg)
|
||||
raise exception.FileFormatError(err_msg)
|
||||
|
||||
elif not isinstance(content, (list, dict)):
|
||||
# testcase file content does not match testcase format
|
||||
err_msg = "Testcase file content format invalid: {}".format(file_path)
|
||||
logging.error(err_msg)
|
||||
raise exception.FileFormatError(err_msg)
|
||||
|
||||
|
||||
class TestcaseParser(object):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user