Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:42:47+00:00 2026-06-10T07:42:47+00:00

generally each lettuce test step takes 1 parameter, is there a way to pass

  • 0

generally each lettuce test step takes 1 parameter, is there a way to pass in multiple arguments in a single step ?

like, can I have this:

@step('I have the number (\d+) and character (\w+)')
def have_the_number(step, number, character ):
    world.number = int(number)
    world.character = str(character)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:42:49+00:00Added an answer on June 10, 2026 at 7:42 am

    Your code is perfectly valid. You can both positional arguments (like *args, just like in your example) as well as named ones (like **kwargs).

    Consider you have the following math.feature:

    Feature: Basic computations
        In order to play with Lettuce
        As beginners
        We will implement addition and subtraction
    
        Scenario: Sum of 0 and 1
            Given I have to add the numbers 0 and 1
            When I compute its factorial
            Then I see the number 1
    
        Scenario: Difference of 3 and 5
            Given I have to substract 5 from 3
            When I compute their difference
            Then I see the number -2
    

    and such steps.py:

    from lettuce import *
    
    @step('I have to add the numbers (\d+) and (\d+)')
    def have_to_add(step, number1, number2):
        world.number1 = int(number1)
        world.number2 = int(number2)
    
    @step('I have to substract (?P<subtrahend>) from (?P<minuend>)')
    def have_to_substract(step, minuend, subtrahend):
        world.minuend = int(minuend)
        world.subtrahend = int(subtrahend)
    
    @step('I compute their difference')
    def compute_difference(step):
        world.number = world.minuend - world.subtrahend
    
    @step('I compute their sum')
    def compute_sum(step):
        world.number = world.number1 + world.number2
    
    @step('I see the number (\d+)')
    def check_number(step, expected):
        expected = int(expected)
        assert world.number == expected, "Got %d" % world.number
    

    Take a closer look at the subtraction example, it shows how you can refer to captured variables by name rather then by position.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a generally accepted way of overriding error (validation) messages from a gem/plugin
I'd like something like this: each[i_, {1,2,3}, Print[i] ] Or, more generally, to destructure
Generally I have the following business model: There're users and groups. Each user belongs
Generally, message boxes work like this: if(ShowMessageBox(Title,Text,MB_YES_NO) == MB_YES) { //the user responded yes
Generally,our fixes/patches for any bugs involves changes in multiple files and we will commit
Generally we import a tlb file at the starting of the program like #include
Generally speaking, I am very happy with the changes in Xcode 3.2. However, there
Generally speaking, what are your recommendations on this? Currently takes close to 10 minutes
Generally , how can you determine how to iterate through an array based on
In console applications there generally is a main file where you type up what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.