Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter readBody deprecation notice in tests #947

Merged
merged 4 commits into from Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_twisted.py
Expand Up @@ -3,6 +3,8 @@
from prometheus_client import CollectorRegistry, Counter, generate_latest

try:
from warnings import filterwarnings

from twisted.internet import reactor
from twisted.trial.unittest import TestCase
from twisted.web.client import Agent, readBody
Expand Down Expand Up @@ -40,6 +42,10 @@ def test_reports_metrics(self):
url = f"http://localhost:{port}/metrics"
d = agent.request(b"GET", url.encode("ascii"))

# Ignore expected DeprecationWarning.
filterwarnings("ignore", category=DeprecationWarning, message="Using readBody "
"with a transport that does not have an abortConnection method")

d.addCallback(readBody)
d.addCallback(self.assertEqual, generate_latest(self.registry))

Expand Down