Skip to content

Fix warnings emitted during tests - #645

Merged
jelmer merged 2 commits into
testing-cabal:masterfrom
stephenfin:warnings-cleanup
Nov 30, 2026
Merged

jelmer merged 2 commits into
testing-cabal:masterfrom
stephenfin:warnings-cleanup

Conversation

@stephenfin

Copy link
Copy Markdown
Contributor

Resolve some DeprecationWarning and ResourceWarning warnings currently seen in tests.

@jelmer jelmer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also just consider dropping the compat code in the next major release?

@jelmer
jelmer enabled auto-merge November 30, 2026 19:27
@stephenfin

Copy link
Copy Markdown
Contributor Author

Maybe we should also just consider dropping the compat code in the next major release?

Oh, yes, that would be my expectation. I don't think we need a new major version atm though?

Move listening port creation to a helper where we can register a cleanup
callback. This resolves warnings like the following currently seen when
running tests:

  /home/stephenfin/dev/testtools/testtools/testcase.py:1172: ResourceWarning:
  unclosed <socket.socket fd=12, family=2, type=1, proto=0, laddr=('127.0.0.1', 42667)>
    return self._get_test_method()()
  ResourceWarning: Enable tracemalloc to get the object allocation traceback

Signed-off-by: Stephen Finucane <stephen@that.guru>
Use a combo of the WarningsFilter and WarningsCapture fixtures to avoid
polluting output and ensure we actually log the deprecation warnings.

Signed-off-by: Stephen Finucane <stephen@that.guru>
@jelmer
jelmer merged commit 33573fb into testing-cabal:master Nov 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants