Skip to content

Commit

Permalink
Filter readBody deprecation notice in tests (#947)
Browse files Browse the repository at this point in the history
* ignore DeprecationWarning.

Signed-off-by: kareza <kareza@qq.com>
  • Loading branch information
karezachen committed Sep 18, 2023
1 parent 34553ad commit 2ff5328
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit 2ff5328

Please sign in to comment.