it¶
it defines a single example. The first argument is a human-readable description, the second is a block containing the test body.
1 2 3 4 5 | |
One-liner form¶
The description is optional. When omitted, Behave derives the description from the first matcher used in the block:
1 2 3 4 5 | |
renders as ⮑ 'should be (1, 2, 3)'. If no matcher runs in the block, Behave falls back to a placeholder of the form example at <basename>:<line>. See subject / is-expected for details.
Multiple expectations¶
An example can contain any number of expect calls. Each failing expectation is recorded; the example fails if at least one expectation fails or the block raises an unhandled exception.
1 2 3 4 5 6 | |
Pending examples¶
You can mark an example as pending by setting its pending flag on the returned object (advanced). The simplest path is to comment out the body or skip writing the assertion until you implement the behavior.
Optional context parameter¶
If your example block accepts a positional parameter, Behave passes a context object that lets you reach let values via method-style access:
1 2 3 4 5 6 7 | |
See let for the various ways to define and consume let values.