8000 Filter `readBody` deprecation notice in tests (#947) · draftcode/client_python@2ff5328 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ff5328

Browse files
authored
Filter readBody deprecation notice in tests (prometheus#947)
* ignore DeprecationWarning. Signed-off-by: kareza <kareza@qq.com>
1 parent 34553ad commit 2ff5328

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/test_twisted.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from prometheus_client import CollectorRegistry, Counter, generate_latest
44

55
try:
6+
from warnings import filterwarnings
7+
68
from twisted.internet import reactor
79
from twisted.trial.unittest import TestCase
810
from twisted.web.client import Agent, readBody
@@ -40,6 +42,10 @@ def test_reports_metrics(self):
4042
url = f"http://localhost:{port}/metrics"
4143
d = agent.request(b"GET", url.encode("ascii"))
4244

45+
# Ignore expected DeprecationWarning.
46+
filterwarnings("ignore", category=DeprecationWarning, message="Using readBody "
47+
"with a transport that does not have an abortConnection method")
48+
4349
d.addCallback(readBody)
4450
d.addCallback(self.assertEqual, generate_latest(self.registry))
4551

0 commit comments

Comments
 (0)
0