Commit b0929bc
committed
Use
pytest 9.1.0 added proper support for `datetime`/`timedelta` in
`pytest.approx()`, and as part of it, it now refuses to guess a
tolerance for these types, raising instead:
TypeError: pytest.approx() requires an explicit tolerance for
datetime/timedelta comparisons: e.g. approx(expected,
abs=timedelta(seconds=1)) or approx(expected, rel=0.01)
This broke 12 tests in `test_clocksinfo.py` and `test_config.py`, which
were using the bare `pytest.approx()` on `timedelta`s instead of the
`approx_time()` helper used everywhere else in this test package.
These assertions never really used a tolerance anyway: all the compared
values are exact, so they only ever succeeded through the exact-equality
short-circuit in `approx()`, before any tolerance was computed.
Switching them to `approx_time()` provides the required tolerance (1ms
by default) and makes the whole test package consistent.
Signed-off-by: Leandro Lucarella <luca-frequenz@llucax.com>approx_time to compare timedeltas in tests1 parent c1befb8 commit b0929bc
2 files changed
Lines changed: 11 additions & 7 deletions
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
144 | | - | |
| 146 | + | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| |||
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
169 | | - | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| |||
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | | - | |
| 224 | + | |
223 | 225 | | |
224 | 226 | | |
225 | 227 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
| 43 | + | |
42 | 44 | | |
43 | | - | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
0 commit comments