fix: exception when teststep name reference former extracted variable

This commit is contained in:
debugtalk
2019-06-25 00:08:42 +08:00
parent 4b56baab1b
commit 3ebf527d9a
3 changed files with 9 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
**Bugfixes**
- add wheel in dev packages
- fix exception when teststep name reference former extracted variable
## 2.1.3 (2019-04-24)

View File

@@ -67,9 +67,13 @@ class HttpRunner(object):
variables = test_dict.get("variables", {})
if isinstance(test.__doc__, parser.LazyString):
parsed_variables = parser.parse_variables_mapping(variables, ignore=True)
test.__doc__ = parser.parse_lazy_data(
test.__doc__, parsed_variables)
try:
parsed_variables = parser.parse_variables_mapping(variables)
test.__doc__ = parser.parse_lazy_data(
test.__doc__, parsed_variables
)
except exceptions.VariableNotFound:
test.__doc__ = str(test.__doc__)
return test

View File

@@ -675,7 +675,7 @@ def extract_variables(content):
return set()
def parse_variables_mapping(variables_mapping, ignore=False):
def parse_variables_mapping(variables_mapping):
""" eval each prepared variable and function in variables_mapping.
Args:
@@ -689,8 +689,6 @@ def parse_variables_mapping(variables_mapping, ignore=False):
"c": {"key": LazyString($b)},
"d": [LazyString($a), 3]
}
ignore (bool): If set True, VariableNotFound will be ignored.
This is used when initializing tests.
Returns:
dict: parsed variables_mapping should not contain any variable or function.
@@ -733,9 +731,6 @@ def parse_variables_mapping(variables_mapping, ignore=False):
# variables_mapping = {"token": LazyString($token)}
# var_name = "key"
# variables_mapping = {"key": [LazyString($key), 2]}
if ignore:
parsed_variables_mapping[var_name] = value
continue
raise exceptions.VariableNotFound(var_name)
if variables: