Merge pull request #542 from HttpRunner/bugfix

2.0.6
This commit is contained in:
debugtalk
2019-03-19 15:00:04 +08:00
committed by GitHub
7 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,16 @@
# Release History
## 2.0.6 (2019-03-18)
**Features**
- create .gitignore file when initializing new project
**Bugfixes**
- fix CSV relative path detection
- fix current validators displaying the former one when they are empty
## 2.0.5 (2019-03-04)
**Features**

View File

@@ -1,7 +1,7 @@
__title__ = 'HttpRunner'
__description__ = 'One-stop solution for HTTP(S) testing.'
__url__ = 'https://github.com/HttpRunner/HttpRunner'
__version__ = '2.0.5'
__version__ = '2.0.6'
__author__ = 'debugtalk'
__author_email__ = 'mail@debugtalk.com'
__license__ = 'Apache-2.0'

View File

@@ -50,6 +50,9 @@ class VariableNotFound(NotFoundError):
class EnvNotFound(NotFoundError):
pass
class CSVNotFound(NotFoundError):
pass
class ApiNotFound(NotFoundError):
pass

View File

@@ -80,6 +80,15 @@ def load_csv_file(csv_file):
]
"""
if not os.path.isabs(csv_file):
project_working_directory = tests_def_mapping["PWD"] or os.getcwd()
# make compatible with Windows/Linux
csv_file = os.path.join(project_working_directory, *csv_file.split("/"))
if not os.path.isfile(csv_file):
# file path not exist
raise exceptions.CSVNotFound(csv_file)
csv_content_list = []
with io.open(csv_file, encoding='utf-8') as csvfile:

View File

@@ -533,6 +533,12 @@ def create_scaffold(project_name):
]
[create_path(p[0], p[1]) for p in path_list]
# create .gitignore file
ignore_file = os.path.join(project_name, ".gitignore")
ignore_content = ".env\nreports/*"
with open(ignore_file, "w") as f:
f.write(ignore_content)
def gen_cartesian_product(*args):
""" generate cartesian product for lists

View File

@@ -6,11 +6,6 @@
var_d: "${gen_random_string(5)}"
var_e: $var_d
PROJECT_KEY: ${ENV(PROJECT_KEY)}
# parameters:
# - "var_a-var_b":
# - [11, 21]
# - [12, 22]
# - "app_version": "${gen_app_version()}"
- test:
name: testcase1-$var_a

View File

@@ -407,9 +407,10 @@ class TestParser(unittest.TestCase):
)
def test_parse_parameters_parameterize(self):
loader.load_project_tests(os.path.join(os.getcwd(), "tests"))
parameters = [
{"app_version": "${parameterize(tests/data/app_version.csv)}"},
{"username-password": "${parameterize(tests/data/account.csv)}"}
{"app_version": "${parameterize(data/app_version.csv)}"},
{"username-password": "${parameterize(data/account.csv)}"}
]
cartesian_product_parameters = parser.parse_parameters(parameters)
self.assertEqual(
@@ -424,7 +425,7 @@ class TestParser(unittest.TestCase):
parameters = [
{"user_agent": ["iOS/10.1", "iOS/10.2", "iOS/10.3"]},
{"app_version": "${gen_app_version()}"},
{"username-password": "${parameterize(tests/data/account.csv)}"}
{"username-password": "${parameterize(data/account.csv)}"}
]
cartesian_product_parameters = parser.parse_parameters(
parameters, functions_mapping=project_mapping["functions"])
@@ -453,8 +454,6 @@ class TestParser(unittest.TestCase):
self.assertEqual(test_dict1["variables"]["var_c"], 3)
self.assertEqual(test_dict1["variables"]["PROJECT_KEY"], "ABCDEFGH")
self.assertEqual(test_dict1["variables"]["var_d"], test_dict1["variables"]["var_e"])
# TODO: parameters
# self.assertEqual(len(parsed_testcases), 2 * 2)
self.assertEqual(parsed_testcases[0]["config"]["name"], '1230')
def test_parse_tests_override_variables(self):