From 2ff532839fd54d7c686837e5955ea0ff9abfab76 Mon Sep 17 00:00:00 2001 From: Kareza Chen Date: Tue, 19 Sep 2023 05:56:01 +0800 Subject: [PATCH] Filter `readBody` deprecation notice in tests (#947) * ignore DeprecationWarning. Signed-off-by: kareza --- tests/test_twisted.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_twisted.py b/tests/test_twisted.py index 3f72d1b1..e63c903e 100644 --- a/tests/test_twisted.py +++ b/tests/test_twisted.py @@ -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 @@ -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))