Как передать параметры в поведение / Python - PullRequest
0 голосов
/ 04 февраля 2020

Интересно, как передать Истинные или Ложные аргументы, такие как. (config_type = True) с использованием поведения в языке python.

Scenario Outline:
Given 
upload xls with parameters "shop" xlsx (path: "./upload12.xlsx") definition named "config_short" and  "<config_type>"

Examples:
      | config_type|
      | False    |

@given('upload xls with parameters "sh" xlsx (path: "./upload12.xlsx") definition named "config_short" and  "{config_type}"')
def step_impl(context, config_type)
definition = someMethod(xlsx_path, config_short, config_type=True)

Это правильный способ передачи таких аргументов в BDD? В следующем тесте я хочу использовать это someMethod, но с config_type = False

1 Ответ

0 голосов
/ 04 февраля 2020

Я думаю, что вы близки, но нужно передать параметр config_type через someMethod:

Scenario Outline:
Given upload xls with parameters "shop" xlsx (path: "./upload12.xlsx") definition named "config_short" and  "<config_type>"

Examples:
      | config_type|
      | False    |

@given('upload xls with parameters "sh" xlsx (path: "./upload12.xlsx") definition named "config_short" and  "{config_type}"')
def step_impl(context, config_type):
    definition = someMethod(xlsx_path, config_short, config_type=config_type)

Тем не менее, вы, возможно, могли бы очистить это в целом с помощью чего-то вроде:

Файл функции:

Scenario Outline:
Given upload xls with parameters "<type>" xlsx (path: "<xls_path>") definition named "<config_name>" and  "<config_type>"

Examples:
      | type | xls_path        | config_name  | config_type|
      | shop | ./upload12.xlsx | config_short | False    |

файл шага:

@given('upload xls with parameters "{type}" xlsx (path: "{xls_path}") definition named "{config_name}" and  "{config_type}"')
def step_impl(context, type, xls_path, config_name, config_type):
    definition = someMethod(xlsx_path=xls_path, config_short=config_short, config_type=config_type)
...