python-trio / python-trio/trio
Catching important warnings in test harness
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
It would be nice if we could make the tests error out on:
- Warning: coroutine '...' was never awaited
- ResourceWarning
What these have in common is that they're both issued by the garbage collector, so the normal way of converting them into errors doesn't work; the only way to detect these is to monkeypatch the warnings module, perhaps by adding an always filter for the relevant warnings and then installing a custom warnings.showwarning hook that records the information somewhere that the test harness can find it.
Some care might be needed to avoid colliding with pytest's warning functionality: https://docs.pytest.org/en/features/warnings.html
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the test harness and reviewing Python's warnings module alongside pytest's warning functionality, especially the interaction described in the issue. Done means the harness reliably fails for unawaited-coroutine warnings and ResourceWarning without conflicting with pytest's warning handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100