File: call_order.md

package info (click to toggle)
python-flexmock 0.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: python: 3,802; makefile: 17; sh: 14
file content (21 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Asserting call order

Flexmock does not enforce call order by default, but it's easy to do if you need
to:

```python
flexmock(plane).should_receive("fly").with_args("left").and_return(
    "ok"
).ordered()

flexmock(plane).should_receive("fly").with_args("right").and_return(
    "ok"
).ordered()
```

The order of the flexmock calls is the order in which these methods will need to
be called by the code under test.

If method `fly()` above is called with the right arguments in the declared order
things will be fine and both will return `"ok"`. But trying to call `fly("right")`
before `fly("left")` will result in an exception.