Commit 40170a6
authored
fix: Report integer count in 'Experiencing problems' status log (#1860)
## Summary
The walrus operator at `_basic_crawler.py:1656` binds less tightly than
`>`, so `failed_requests := X - Y > 0` was parsed as `failed_requests :=
((X - Y) > 0)` per [PEP 572](https://peps.python.org/pep-0572/). As a
result, `failed_requests` was assigned a `bool` instead of the integer
difference, and the periodic status log emitted:
```
Experiencing problems, True failed requests since last status update.
```
instead of the actual count.
## Fix
Move the parentheses so `:=` captures the integer subtraction and `> 0`
sits outside.
## Regression test
Added `test_status_message_reports_failed_request_count`, which directly
invokes `_crawler_state_task` with a mocked `_statistics.state` and a
separate `_previous_crawler_state`, asserting the rendered message
contains the integer count `3`, not `True`.1 parent 3c594fe commit 40170a6
2 files changed
Lines changed: 25 additions & 7 deletions
File tree
- src/crawlee/crawlers/_basic
- tests/unit/crawlers/_basic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
1662 | 1660 | | |
1663 | 1661 | | |
1664 | 1662 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
1736 | 1735 | | |
1737 | 1736 | | |
1738 | 1737 | | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1739 | 1759 | | |
1740 | 1760 | | |
1741 | 1761 | | |
| |||
0 commit comments