fixup! Add test for inherited UNIX sockets

Eliminate dependency on httpunixsocketconnection; it does not declare
compatibility with Python 3.7.

Patching an HTTPConnection object like this is hackish, but may be good
enough for a test suite. I think it's pretty unlikely to lead to a false
negative.
This commit is contained in:
InvalidInterrupt 2023-09-05 00:15:06 -07:00
parent 50829d9242
commit 34e247547c
2 changed files with 9 additions and 4 deletions

View File

@ -42,7 +42,6 @@ console_scripts =
[options.extras_require]
tests =
django
httpunixsocketconnection
hypothesis
pytest
pytest-asyncio

View File

@ -1,13 +1,13 @@
import os
import socket
import weakref
from http.client import HTTPConnection
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest import skipUnless
import test_http_response
from http_base import DaphneTestCase
from httpunixsocketconnection import HTTPUnixSocketConnection
__all__ = ["UnixSocketFDDaphneTestCase", "TestInheritedUnixSocket"]
@ -41,8 +41,14 @@ class UnixSocketFDDaphneTestCase(DaphneTestCase):
@classmethod
def _get_instance_http_connection(cls, test_app, *, timeout):
socket_name = cls._get_instance_socket_path(test_app)
return HTTPUnixSocketConnection(unix_socket=socket_name, timeout=timeout)
def connect():
conn.sock = cls._get_instance_raw_socket_connection(
test_app, timeout=timeout
)
conn = HTTPConnection("", timeout=timeout)
conn.connect = connect
return conn
@skipUnless(hasattr(socket, "AF_UNIX"), "AF_UNIX support not present.")