mirror of
https://github.com/django/daphne.git
synced 2024-11-25 01:03:45 +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]
|
[options.extras_require]
|
||||||
tests =
|
tests =
|
||||||
django
|
django
|
||||||
httpunixsocketconnection
|
|
||||||
hypothesis
|
hypothesis
|
||||||
pytest
|
pytest
|
||||||
pytest-asyncio
|
pytest-asyncio
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import weakref
|
import weakref
|
||||||
|
from http.client import HTTPConnection
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from unittest import skipUnless
|
from unittest import skipUnless
|
||||||
|
|
||||||
import test_http_response
|
import test_http_response
|
||||||
from http_base import DaphneTestCase
|
from http_base import DaphneTestCase
|
||||||
from httpunixsocketconnection import HTTPUnixSocketConnection
|
|
||||||
|
|
||||||
__all__ = ["UnixSocketFDDaphneTestCase", "TestInheritedUnixSocket"]
|
__all__ = ["UnixSocketFDDaphneTestCase", "TestInheritedUnixSocket"]
|
||||||
|
|
||||||
|
@ -41,8 +41,14 @@ class UnixSocketFDDaphneTestCase(DaphneTestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_instance_http_connection(cls, test_app, *, timeout):
|
def _get_instance_http_connection(cls, test_app, *, timeout):
|
||||||
socket_name = cls._get_instance_socket_path(test_app)
|
def connect():
|
||||||
return HTTPUnixSocketConnection(unix_socket=socket_name, timeout=timeout)
|
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.")
|
@skipUnless(hasattr(socket, "AF_UNIX"), "AF_UNIX support not present.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user