mirror of
https://github.com/django/daphne.git
synced 2024-11-21 23:46:33 +03:00
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:
parent
50829d9242
commit
34e247547c
|
@ -42,7 +42,6 @@ console_scripts =
|
|||
[options.extras_require]
|
||||
tests =
|
||||
django
|
||||
httpunixsocketconnection
|
||||
hypothesis
|
||||
pytest
|
||||
pytest-asyncio
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue
Block a user