是否可以在pytest-bdd中使用*args之类的步骤参数?
例如,我的场景:
Scenario: Data Creation
Given login with USER1 and role ADMIN
Then set expert portal mode
Then fill section Name with Alexa
Then fill section Phonenumbers with 490000000,490000001
Then fill section Kontakt with admin@yahoo.com,AdminName,490000002步骤执行:
@then(parsers.parse("fill section {section_name} with {fill_data}"))
def fill_section(app, section_name, fill_data):
app.siptrunk.fill_section(section_name, fill_data)和执行情况:
def fill_section(self, section, *args):
...some code...如何在“步骤实现”中处理*args以正确地将参数传递到函数中?
发布于 2022-10-05 12:40:32
我认为使用*args是不可能的,可以使用list作为step参数,但是对于解析,需要使用:cfparse
@then(parsers.cfparse("fill section {section_name} with {fill_data:Number+}", extra_types={"Number": int}))
def fill_section(app, section_name, fill_data):
type(fill_data) # <class 'list'>https://stackoverflow.com/questions/70844869
复制相似问题