1+ from ast import literal_eval
12from pytest_bdd import then
23from pytest_bdd import parsers
34from functools import partial
@@ -29,6 +30,12 @@ def match(matcher, *args):
2930 return matcher ()
3031
3132
33+ def to_array (string ):
34+ if string .startswith ("[" ) and string .endswith ("]" ):
35+ return literal_eval (string )
36+ else :
37+ return string
38+
3239@then (parsers .re ("allure report has result for (?:\" )(?P<scenario_name>[\\ w|\\ s|,]*)(?:\" ) scenario" ))
3340def match_scenario (allure_report , context , scenario_name ):
3441 matcher = partial (match , has_test_case , scenario_name )
@@ -52,14 +59,15 @@ def item_history_id(allure_report, context, item):
5259
5360@then (parsers .re ("this (?P<item>\\ w+) "
5461 "has parameter (?:\" )(?P<param_name>[\\ w|\\ s]*)(?:\" ) "
55- "with value (?:\" )(?P<param_value>[\\ w|\\ s]*)(?:\" )" ))
62+ "with value (?:\" )(?P<param_value>[\\ w|\\ s|,|\\ [|\\ ]|<|>|']*)(?:\" )" ),
63+ converters = {'param_value' : to_array })
5664def item_parameter (allure_report , context , item , param_name , param_value ):
5765 context_matcher = context [item ]
5866 matcher = partial (context_matcher , has_parameter , param_name , param_value )
5967 assert_that (allure_report , matcher ())
6068
6169
62- @then (parsers .re ("this (?P<item>\\ w+) contains (?:\" )(?P<step>[\\ w|\\ s|>|<]+)(?:\" ) step" ))
70+ @then (parsers .re ("this (?P<item>\\ w+) contains (?:\" )(?P<step>[\\ w|\\ s|>|<|,| \\ [| \\ ]|' ]+)(?:\" ) step" ))
6371def step_step (allure_report , context , item , step ):
6472 context_matcher = context [item ]
6573 matcher = partial (context_matcher , has_step , step )
0 commit comments