Pytest-BDD step arguments as *args

700 views Asked by At

is it possible to use *args like step arguments in pytest-bdd?

For example my Scenario:

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 [email protected],AdminName,490000002

Step Implementation:

@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)

And implementation:

def fill_section(self, section, *args):
 ...some code...

How can I process *args in "Step Implementation" to correctly pass parameters into function?

1

There are 1 answers

0
Marcin Kądziela On

I think it's not possibile to use *args, it's possible to use list as step argument, but for parsing you need to use: 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'>