From 34e247547c6178048127df6ecf4b3d951648db9f Mon Sep 17 00:00:00 2001 From: InvalidInterrupt Date: Tue, 5 Sep 2023 00:15:06 -0700 Subject: [PATCH] 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. --- setup.cfg | 1 - tests/test_unixsocket.py | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index af31319..c6afb6e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -42,7 +42,6 @@ console_scripts = [options.extras_require] tests = django - httpunixsocketconnection hypothesis pytest pytest-asyncio diff --git a/tests/test_unixsocket.py b/tests/test_unixsocket.py index 821517a..46ad4f9 100644 --- a/tests/test_unixsocket.py +++ b/tests/test_unixsocket.py @@ -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.")