python-trio / python-trio/trio

Catching important warnings in test harness

Open
#169 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pytest-trio relevant user happiness
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.