Behave - Step Parameters

We can have parameters within the step names. These parameters can be taken care of by the regular expressions or by the default or extended parser with the help of the use_step_matcher method.


Modify the parameter matcher in parsing the step text. There are multiple in-built parsers present in Behave, as explained below −

  • parse − It gives an easy parser that restores regular expression for the step parameters with plain syntax. For example, {parameter: type}. It allows type conversion with type converters.

  • cfparse − It has the Cardinality Field (CF) support. By default, it generates the missing type converters for connected cardinality (if type converter for cardinality equal to one is given). It can support the below parse expressions −

    {values:Type+} – Cardinality=1..N, many

    {values:Type*} – Cardinality=0..N, many0

    {values:Type?} – Cardinality=0..1, optional

    It allows type conversion with type converters.

  • re − It utilises the complete regular expressions to parse the clause. We have to take the help of the named groups (? P<name>…) to declare variables obtained from the text and then feed it to the step ().

We can have our customised matcher along with new data types with the help of the register_type method.


Registers a user defined type for parsing during type conversion at the time of step matching.

class behave.matchers.Matcher(func, pattern ,step_type=None)

It extracts the parameters out of step names.

  • pattern − The pattern matching associated with the step function.

  • func − The step function is the pattern is associated with.

  • check_match(step) − To match with the step name provided.

  • describe(schema=None) − Give description in form of text of the function or matcher object.

  • regex_pattern: Yields the utilised textual regex expression.

class behave.model_core.Argument(start, end, original, value, name=Name)

An argument for a step name in the feature file obtained with step decorator parameters.

The attributes are as follows −

  • original − The original text which is matched in the name of the step.

  • value − The value of the argument which is type converted.

  • name − The argument name. The value is set to None, if the parameter is not given.

  • start − The starting index of the argument in step name.

  • end − The ending index of the argument in step name.

class behave.matchers.Match(func, arguments=None)

A step in the feature file which is parameter-matched and obtained with step decorator parameters.

The attributes are as follows −

  • func − The step function which is applicable to the given match.

  • arguments − The argument list the instances having the matched parameter obtained from the name of the step.