1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-06 11:00:46 +00:00

Silence the readBody warning.

This commit is contained in:
Andrey Rakhmatullin 2025-01-28 02:08:49 +05:00
parent bc1aeeefc9
commit 0d2d2892ba

View File

@ -9,7 +9,7 @@ from typing import Any
import OpenSSL.SSL
import pytest
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from twisted.internet.defer import Deferred, inlineCallbacks
from twisted.protocols.policies import WrappingFactory
from twisted.trial import unittest
from twisted.web import server, static
@ -79,7 +79,15 @@ class ContextFactoryBaseTestCase(unittest.TestCase):
response: TxResponse = await maybe_deferred_to_future(
agent.request(b"GET", url.encode(), bodyProducer=body_producer)
)
return await maybe_deferred_to_future(readBody(response)) # type: ignore[arg-type]
with warnings.catch_warnings():
# https://github.com/twisted/twisted/issues/8227
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r".*does not have an abortConnection method",
)
d: Deferred[bytes] = readBody(response) # type: ignore[arg-type]
return await maybe_deferred_to_future(d)
class ContextFactoryTestCase(ContextFactoryBaseTestCase):