repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
gunicorn | tests/test_asgi_keepalive_smuggling.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""End-to-end regression test for the keepalive smuggling guard.
Drives an ``ASGIProtocol`` against a fake transport with two pipelined
requests: the first POST advertises a Content-Length the client never
finishe... | 190 | 5,551 |
gunicorn | tests/test_http2_connection.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 server connection."""
import pytest
from unittest import mock
from io import BytesIO
# Check if h2 is available for integration tests
try:
import h2.connection
im... | 1,196 | 40,143 |
gunicorn | tests/test_reload.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import unittest.mock as mock
from gunicorn.app.base import Application
from gunicorn.workers.base import Worker
from gunicorn.reloader import reloader_engines
class ReloadApp(Application):
def __init__(self)... | 73 | 1,957 |
gunicorn | tests/test_asgi_header_security.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI header security tests.
Tests for header validation, normalization, and injection prevention
to ensure secure HTTP header handling per ASGI 3.0 and RFC 9110/9112.
"""
import pytest
from gunicorn.asgi.par... | 374 | 11,545 |
gunicorn | tests/test_config.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import re
import sys
import tempfile
import pytest
from gunicorn import config
from gunicorn.config import _get_default_control_socket
from gunicorn.app.base import Application
from gunicorn.app.wsgiapp... | 592 | 17,865 |
gunicorn | tests/test_http2_integration.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Integration tests for HTTP/2 with full request/response cycles."""
import pytest
from io import BytesIO
# Check if h2 is available
try:
import h2.connection
import h2.config
i... | 643 | 21,571 |
gunicorn | tests/support_dirty_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Support module for dirty app tests."""
from gunicorn.dirty.app import DirtyApp
class TestDirtyApp(DirtyApp):
"""A simple dirty app for testing."""
def __init__(self):
self.initialized = False... | 158 | 3,768 |
gunicorn | tests/test_http2_stream.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 stream state management."""
import pytest
from gunicorn.http2.stream import HTTP2Stream, StreamState
from gunicorn.http2.errors import HTTP2StreamError
class MockConnec... | 828 | 27,766 |
gunicorn | tests/test_asgi_parser_validation.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for ASGI callback parser header validation.
These tests verify that PythonProtocol correctly validates HTTP headers
and body framing according to RFC 9110 and RFC 9112.
"""
import pytest
from gunicorn.a... | 419 | 13,328 |
gunicorn | tests/test_dirty_errors.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty errors module."""
import pytest
from gunicorn.dirty.errors import (
DirtyError,
DirtyNoWorkersAvailableError,
)
class TestDirtyNoWorkersAvailableError:
"""Tests for DirtyNoWorkers... | 77 | 2,679 |
gunicorn | tests/test_asgi_valid_requests.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test valid HTTP requests against ASGI callback parser.
Runs the same .http test files as test_valid_requests.py but using
the ASGI PythonProtocol callback parser.
"""
import glob
import os
import pytest
impo... | 53 | 1,728 |
gunicorn | tests/test_util.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import pytest
from gunicorn import util
from gunicorn.errors import AppImportError
from urllib.parse import SplitResult
@pytest.mark.parametrize('test_input, expected', [
('unix://var/run/test.sock... | 132 | 4,345 |
gunicorn | tests/test_asgi_protocol_compat.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Protocol-level tests reproducing ASGI framework compatibility failures.
These tests verify gunicorn's ASGI protocol handling without needing
Docker or external frameworks. They target specific issues discovere... | 1,199 | 42,913 |
gunicorn | tests/test_python_protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Tests for PythonProtocol callback-based HTTP parser.
"""
import pytest
from gunicorn.asgi.parser import PythonProtocol, CallbackRequest, ParseError
class TestPythonProtocolBasic:
"""Test basic request pa... | 519 | 15,903 |
gunicorn | tests/test_http2_request.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 request and body classes."""
import pytest
from gunicorn.http2.request import HTTP2Request, HTTP2Body
from gunicorn.http2.stream import HTTP2Stream
class MockConnection... | 722 | 22,911 |
gunicorn | tests/test_asgi_websocket_enhanced.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Enhanced WebSocket ASGI tests.
Tests for WebSocket message size limits, connection rejection,
subprotocol negotiation, and compression per ASGI 3.0 and RFC 6455.
"""
import struct
from unittest import mock
i... | 499 | 16,338 |
gunicorn | tests/test_asgi_streaming.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI streaming response tests.
Tests for chunked transfer encoding, Server-Sent Events (SSE),
and streaming response handling.
"""
from unittest import mock
import pytest
from gunicorn.config import Config
... | 582 | 19,742 |
gunicorn | tests/test_asgi_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI 3.0 specification compliance tests.
Tests that gunicorn's ASGI implementation conforms to the ASGI 3.0 spec:
https://asgi.readthedocs.io/en/latest/specs/main.html
"""
from unittest import mock
import py... | 1,108 | 38,712 |
gunicorn | tests/test_ssl.py | .py | # Copyright 2013 Dariusz Suchojad <dsuch at zato.io>
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import pytest
from gunicorn.config import (
KeyFile, CertFile, CACerts, SuppressRaggedEOFs,
DoHandshakeOnConnect, Setting, Ciphers,
)
ssl = pytest.impo... | 66 | 1,990 |
gunicorn | tests/test_header_policy_parity.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Parity tests for WSGI header policy across Python and fast parsers.
These checks ensure that Expect, secure_scheme_headers, forwarder_headers,
and the forwarded_allow_ips trust gate are enforced identically reg... | 186 | 5,648 |
gunicorn | tests/test_control_socket_integration.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Integration tests for control socket fork safety.
These tests verify that the control socket server properly handles fork()
with different worker types (sync, gthread, gevent) without causing deadlocks.
"""
im... | 474 | 16,479 |
gunicorn | tests/test_asgi_worker.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Tests for the ASGI worker.
Includes unit tests for worker components and integration tests
that actually start the server and make HTTP requests.
"""
import asyncio
import errno
import os
import socket
from u... | 902 | 29,009 |
gunicorn | tests/test_early_hints.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP 103 Early Hints support (RFC 8297)."""
import pytest
from unittest import mock
from io import BytesIO
# Check if h2 is available for HTTP/2 tests
try:
import h2.connect... | 472 | 15,952 |
gunicorn | tests/test_dirty_stash.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty stash (shared state) functionality."""
import pytest
from gunicorn.dirty.stash import (
StashClient,
StashTable,
StashError,
StashTableNotFoundError,
StashKeyNotFoundError,
... | 207 | 6,800 |
gunicorn | tests/test_asgi_proxy_protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""ASGI PROXY protocol parser tests.
Covers the validation gaps that the WSGI parser already enforces:
- v1 TCP4/TCP6 addresses must be valid IP addresses (inet_pton).
- v2 must reject non-STREAM (UDP) protocols w... | 87 | 3,312 |
gunicorn | tests/support_dirty_apps.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Support module for multi-app dirty tests.
Provides test applications with distinct behaviors for verifying
that requests are correctly routed to the appropriate app.
"""
from gunicorn.dirty.app import DirtyApp... | 141 | 3,185 |
gunicorn | tests/treq_asgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test request utilities for ASGI callback parser.
Provides the same test infrastructure as treq.py but for testing
the ASGI callback parsers (PythonProtocol and H1CProtocol).
"""
import importlib.machinery
impo... | 355 | 12,258 |
gunicorn | tests/test_http2_config.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 configuration settings."""
import pytest
from gunicorn import config
from gunicorn.config import Config
class TestHttpProtocolsConfig:
"""Test http_protocols config... | 344 | 11,196 |
gunicorn | tests/test_http2_async_connection.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for async HTTP/2 server connection."""
import asyncio
import pytest
from unittest import mock
from io import BytesIO
# Check if h2 is available for integration tests
try:
import... | 1,017 | 34,178 |
gunicorn | tests/test_dirty_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty app module."""
import pytest
from gunicorn.dirty.app import (
DirtyApp,
load_dirty_app,
load_dirty_apps,
parse_dirty_app_spec,
)
from gunicorn.dirty.errors import DirtyAppError,... | 348 | 12,463 |
gunicorn | tests/test_asgi_invalid_requests.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test invalid HTTP requests against ASGI callback parser.
Runs the same .http test files as test_invalid_requests.py but using
the ASGI callback parsers (PythonProtocol and H1CProtocol).
"""
import glob
import ... | 88 | 3,190 |
gunicorn | tests/test_gtornado.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for the tornado worker."""
import os
from unittest import mock
import pytest
tornado = pytest.importorskip("tornado")
from gunicorn.config import Config
from gunicorn.workers import gtornado
class Fa... | 512 | 15,214 |
gunicorn | tests/test_pidfile.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import errno
from unittest import mock
import gunicorn.pidfile
def builtin(name):
return 'builtins.{}'.format(name)
@mock.patch(builtin('open'), new_callable=mock.mock_open)
def test_validate_no_file(_open... | 50 | 1,500 |
gunicorn | tests/test_dirty_integration.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Integration tests for dirty arbiter with main arbiter."""
import os
import struct
import pytest
from gunicorn.arbiter import Arbiter
from gunicorn.config import Config
from gunicorn.app.base import BaseApplica... | 383 | 13,444 |
gunicorn | tests/test_http.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import io
import t
import pytest
from unittest import mock
from gunicorn import util
from gunicorn.http.body import Body, LengthReader, EOFReader
from gunicorn.http.wsgi import FileWrapper, Response
from gunicorn.... | 440 | 13,615 |
gunicorn | tests/test_asgi_protocol_http.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI HTTP protocol tests.
Tests for HTTP connection management, Expect: 100-continue,
body size handling, and chunked encoding per ASGI 3.0 and HTTP/1.1 specs.
"""
from unittest import mock
import pytest
fr... | 512 | 14,683 |
gunicorn | tests/test_sock.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from unittest import mock
from gunicorn import sock
@mock.patch('os.stat')
def test_create_sockets_unix_bytes(stat):
conf = mock.Mock(address=[b'127.0.0.1:8000'])
log = mock.Mock()
with mock.patch.ob... | 57 | 1,853 |
gunicorn | tests/support.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import functools
import sys
import unittest
import platform
from wsgiref.validate import validator
HOST = "127.0.0.1"
def create_app(name="World", count=1):
message = (('Hello, %s!\n' % name) * count).encode... | 68 | 1,851 |
gunicorn | tests/test_systemd.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
from contextlib import contextmanager
import os
from unittest import mock
import pytest
from gunicorn import systemd
@contextmanager
def check_environ(unset=True):
"""
A context manager that asserts pos... | 61 | 2,027 |
gunicorn | tests/test_asgi_lifespan.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI lifespan protocol tests.
Tests for lifespan message formats and behavior per ASGI 3.0 specification.
"""
import asyncio
from unittest import mock
import pytest
# ======================================... | 425 | 14,183 |
gunicorn | tests/test_uwsgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import io
import pytest
from unittest import mock
from gunicorn.uwsgi import (
UWSGIRequest,
UWSGIParser,
UWSGIParseException,
InvalidUWSGIHeader,
UnsupportedModifier,
ForbiddenUWSGIRequest... | 436 | 14,386 |
gunicorn | tests/test_dirty_protocol.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty worker binary protocol module."""
import asyncio
import os
import socket
import struct
import pytest
from gunicorn.dirty.protocol import (
BinaryProtocol,
DirtyProtocol,
make_reques... | 568 | 20,754 |
gunicorn | tests/t.py | .py | # Copyright 2009 Paul J. Davis <paul.joseph.davis@gmail.com>
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import io
import os
import tempfile
dirname = os.path.dirname(__file__)
from gunicorn.http.parser import RequestParser
def data_source(fname):
bu... | 67 | 1,576 |
gunicorn | tests/test_logger.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import datetime
from types import SimpleNamespace
import pytest
from gunicorn.config import Config
from gunicorn.glogging import Logger
def test_atoms_defaults():
response = SimpleNamespace(
status=... | 96 | 3,246 |
gunicorn | tests/test_statsd.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import io
import logging
import os
import shutil
import socket
import tempfile
from datetime import timedelta
from types import SimpleNamespace
from gunicorn.config import Config
from gunicorn.instrument.statsd im... | 162 | 4,916 |
gunicorn | tests/test_dirty_client.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty client module."""
import os
import socket
import tempfile
import threading
import pytest
from gunicorn.dirty.client import (
DirtyClient,
get_dirty_client,
get_dirty_socket_path,
... | 325 | 10,548 |
gunicorn | tests/test_http2_alpn.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 ALPN negotiation."""
import ssl
import pytest
from unittest import mock
from gunicorn import sock
def create_mock_ssl_socket(alpn_protocol=None):
"""Create a mock S... | 356 | 12,968 |
gunicorn | tests/test_dirty_arbiter.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty arbiter module."""
import asyncio
import os
import signal
import struct
import tempfile
import pytest
from gunicorn.config import Config
from gunicorn.dirty.arbiter import DirtyArbiter
from gun... | 1,430 | 42,883 |
gunicorn | tests/test_http2_errors.py | .py | # -*- coding: utf-8 -
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for HTTP/2 error classes."""
import pytest
from gunicorn.http2.errors import (
HTTP2Error,
HTTP2ProtocolError,
HTTP2InternalError,
HTTP2FlowControlError,
HTTP2Se... | 229 | 6,662 |
gunicorn | tests/test_dirty_hooks.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty arbiter hooks."""
import pytest
from gunicorn.config import Config
class TestDirtyHooksConfig:
"""Tests for dirty hook configuration settings."""
def test_on_dirty_starting_default(s... | 110 | 3,147 |
gunicorn | tests/test_signal_integration.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Integration tests for arbiter signal handling.
These tests start a real gunicorn process and verify signal handling
works correctly with actual requests and signals.
"""
import os
import signal
import socket
i... | 228 | 6,995 |
gunicorn | tests/test_dirty_tlv.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for dirty TLV binary encoder/decoder."""
import math
import struct
import pytest
from gunicorn.dirty.tlv import (
TLVEncoder,
TYPE_NONE,
TYPE_BOOL,
TYPE_INT64,
TYPE_FLOAT64,
TYPE_... | 555 | 18,807 |
gunicorn | tests/test_arbiter.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
import os
import signal
from unittest import mock
import pytest
import gunicorn.app.base
import gunicorn.arbiter
import gunicorn.errors
from gunicorn.config import ReusePort
class DummyApplication(gunicorn.app.... | 741 | 28,711 |
gunicorn | tests/test_gthread.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Tests for the gthread worker."""
import errno
import fcntl
import os
import selectors
import threading
import time
from collections import deque
from concurrent import futures
from unittest import mock
import ... | 1,779 | 56,503 |
gunicorn | tests/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Pytest configuration for gunicorn tests."""
import os
import sys
import pytest
# Add the tests directory to sys.path so test support modules can be imported
# as 'tests.module_name' (e.g., 'tests.support_dirt... | 32 | 1,193 |
gunicorn | tests/docker/asgi_compliance/test_framework_integration.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Framework integration tests for ASGI.
Tests integration with popular ASGI frameworks like Starlette and FastAPI.
"""
import json
import pytest
pytestmark = [
pytest.mark.docker,
pytest.mark.asgi,
... | 503 | 20,172 |
gunicorn | tests/docker/asgi_compliance/test_concurrency.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Concurrency integration tests for ASGI.
Tests concurrent connections, mixed protocols, and load handling.
"""
import asyncio
import json
import pytest
pytestmark = [
pytest.mark.docker,
pytest.mark.... | 477 | 17,591 |
gunicorn | tests/docker/asgi_compliance/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI Compliance Docker Integration Tests.
This package contains Docker-based integration tests for ASGI compliance.
"""
| 10 | 231 |
gunicorn | tests/docker/asgi_compliance/test_streaming_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Streaming compliance integration tests for ASGI.
Tests chunked transfer encoding, Server-Sent Events (SSE),
and streaming response handling.
"""
import json
import time
import pytest
pytestmark = [
pyte... | 441 | 17,370 |
gunicorn | tests/docker/asgi_compliance/test_lifespan_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Lifespan compliance integration tests for ASGI.
Tests the ASGI lifespan protocol including startup, shutdown,
and state sharing between lifespan and request handlers.
"""
import pytest
pytestmark = [
pyt... | 242 | 9,298 |
gunicorn | tests/docker/asgi_compliance/test_http_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
HTTP compliance integration tests for ASGI.
Tests HTTP request/response handling, headers, methods, status codes,
and ASGI scope correctness through actual HTTP requests.
"""
import json
import pytest
pytes... | 533 | 20,668 |
gunicorn | tests/docker/asgi_compliance/test_websocket_compliance.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
WebSocket compliance integration tests for ASGI.
Tests RFC 6455 WebSocket protocol compliance including handshake,
messaging, close codes, and subprotocol negotiation.
"""
import asyncio
import json
import p... | 703 | 29,301 |
gunicorn | tests/docker/asgi_compliance/test_http2_asgi.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
HTTP/2 ASGI integration tests.
Tests HTTP/2 specific functionality with ASGI applications.
"""
import json
import pytest
pytestmark = [
pytest.mark.docker,
pytest.mark.asgi,
pytest.mark.http2,
... | 441 | 16,726 |
gunicorn | tests/docker/asgi_compliance/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Pytest fixtures for ASGI compliance Docker integration tests."""
import subprocess
import time
import socket
from pathlib import Path
import pytest
# Directory containing this conftest.py
DOCKER_DIR = Path(__... | 374 | 12,246 |
gunicorn | tests/docker/asgi_compliance/apps/http_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
HTTP test application for ASGI compliance testing.
Provides various endpoints to test HTTP request/response handling,
headers, body processing, and ASGI scope inspection.
"""
import json
import time
async d... | 603 | 16,869 |
gunicorn | tests/docker/asgi_compliance/apps/__init__.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
ASGI test applications for compliance testing.
"""
| 8 | 161 |
gunicorn | tests/docker/asgi_compliance/apps/websocket_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
WebSocket test application for ASGI compliance testing.
Provides various WebSocket endpoints to test RFC 6455 compliance,
message handling, and protocol features.
"""
import json
async def app(scope, receiv... | 497 | 14,594 |
gunicorn | tests/docker/asgi_compliance/apps/lifespan_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Lifespan test application for ASGI compliance testing.
Tests the ASGI lifespan protocol including startup, shutdown,
and state sharing between lifespan and request handlers.
"""
import json
import os
import t... | 304 | 8,704 |
gunicorn | tests/docker/asgi_compliance/apps/framework_apps.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Framework integration test applications.
Tests integration with popular ASGI frameworks like Starlette and FastAPI.
These apps require the frameworks to be installed.
"""
import json
import os
# Framework av... | 397 | 12,741 |
gunicorn | tests/docker/asgi_compliance/apps/main_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Main ASGI application for compliance testing.
Routes requests to appropriate test applications based on path prefix.
This is the primary entry point for Docker-based integration tests.
"""
import json
import ... | 245 | 7,939 |
gunicorn | tests/docker/asgi_compliance/apps/streaming_app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Streaming test application for ASGI compliance testing.
Provides endpoints for testing chunked transfer encoding,
Server-Sent Events (SSE), and streaming responses.
"""
import asyncio
import json
import time
... | 477 | 13,071 |
gunicorn | tests/docker/test_asgi_uwsgi/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Simple ASGI test application for uWSGI protocol testing."""
async def app(scope, receive, send):
"""Simple ASGI application that echoes request info."""
if scope["type"] == "lifespan":
while Tr... | 50 | 1,482 |
gunicorn | tests/docker/http2/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test WSGI application for HTTP/2 Docker integration tests."""
import json
def app(environ, start_response):
"""Simple WSGI app for testing HTTP/2 functionality."""
path = environ.get('PATH_INFO', '/')... | 160 | 5,192 |
gunicorn | tests/docker/http2/test_http2_docker.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""HTTP/2 Docker integration tests.
These tests verify HTTP/2 functionality with real connections to gunicorn
running in Docker containers, both directly and through an nginx proxy.
"""
import asyncio
import ssl
... | 393 | 15,679 |
gunicorn | tests/docker/http2/conftest.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Pytest fixtures for HTTP/2 Docker integration tests."""
import subprocess
import time
from pathlib import Path
import pytest
# Directory containing this conftest.py
DOCKER_DIR = Path(__file__).parent
CERTS_DI... | 201 | 5,821 |
gunicorn | tests/docker/dirty_ttin_ttou/test_ttin_ttou_docker.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Docker integration tests for dirty arbiter TTIN/TTOU signals."""
import os
import subprocess
import time
from pathlib import Path
import pytest
import requests
pytestmark = [
pytest.mark.docker,
pyte... | 236 | 7,585 |
gunicorn | tests/docker/dirty_ttin_ttou/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Test app with multiple dirty tasks for TTIN/TTOU testing."""
import json
import time
from gunicorn.dirty import DirtyApp, get_dirty_client
# Unlimited workers - runs on all dirty workers
class UnlimitedTask(... | 76 | 2,353 |
gunicorn | tests/docker/dirty_ttin_ttou/gunicorn_conf.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Gunicorn configuration for TTIN/TTOU testing."""
bind = "0.0.0.0:8000"
workers = 2
worker_class = "gthread"
threads = 2
# Dirty arbiter config
dirty_apps = [
"app:UnlimitedTask",
"app:LimitedTask", # ... | 24 | 444 |
gunicorn | tests/docker/asgi/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""Simple ASGI test application for HTTP protocol testing."""
async def app(scope, receive, send):
"""Simple ASGI application that echoes request info."""
if scope["type"] == "lifespan":
while Tru... | 50 | 1,481 |
gunicorn | tests/docker/dirty_arbiter/app.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Simple WSGI and Dirty applications for integration testing.
"""
from gunicorn.dirty.app import DirtyApp
def application(environ, start_response):
"""Simple WSGI application."""
start_response('200 OK... | 30 | 688 |
gunicorn | tests/docker/dirty_arbiter/test_parent_death.py | .py | #!/usr/bin/env python
#
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Docker-based integration tests for dirty arbiter process lifecycle.
These tests verify:
1. Dirty arbiter self-terminates when main arbiter dies unexpectedly (SIGKILL)
2. Orphan cleanup wo... | 528 | 18,623 |
gunicorn | tests/docker/dirty_arbiter/gunicorn_conf.py | .py | #
# This file is part of gunicorn released under the MIT license.
# See the NOTICE for more information.
"""
Gunicorn configuration for integration tests.
"""
bind = "0.0.0.0:8000"
workers = 1
worker_class = "sync"
dirty_workers = 1
dirty_apps = ["app:TestDirtyApp"]
dirty_timeout = 30
dirty_graceful_timeout = 5
timeo... | 21 | 399 |
gunicorn | tests/docker/asgi_framework_compat/conftest.py | .py | """
Pytest configuration for ASGI Framework Compatibility Tests
This module provides fixtures for parameterized testing across multiple
ASGI frameworks running in Docker containers with gunicorn's ASGI worker.
"""
import asyncio
import json
import os
import subprocess
import time
from typing import AsyncGenerator
im... | 212 | 5,936 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_streaming.py | .py | """
Streaming Response Tests
Tests chunked streaming and Server-Sent Events across frameworks.
"""
import asyncio
import json
import pytest
pytestmark = pytest.mark.streaming
class TestChunkedStreaming:
"""Test chunked transfer encoding responses."""
async def test_streaming_response(self, http_client):... | 99 | 3,343 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_lifespan_scope.py | .py | """
Lifespan Protocol Tests
Tests ASGI 3.0 lifespan protocol compliance across frameworks.
"""
import pytest
pytestmark = pytest.mark.lifespan
class TestLifespanStartup:
"""Test lifespan startup handling."""
async def test_startup_was_called(self, http_client):
"""Startup handler was called."""
... | 100 | 3,447 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_http_messages.py | .py | """
HTTP Message Type Tests
Tests ASGI 3.0 HTTP request/response message handling.
"""
import pytest
pytestmark = pytest.mark.http
class TestHttpRequestBody:
"""Test HTTP request body handling."""
async def test_echo_empty_body(self, http_client):
"""Echo endpoint handles empty body."""
r... | 129 | 4,643 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_websocket_scope.py | .py | """
WebSocket Scope Compliance Tests
Tests ASGI 3.0 WebSocket scope compliance across frameworks.
"""
import asyncio
import json
import pytest
import websockets
from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError
from frameworks.contract import (
ASGI_WEBSOCKET_SCOPE_REQUIRED_KEYS,
V... | 194 | 6,844 |
gunicorn | tests/docker/asgi_framework_compat/tests/test_http_scope.py | .py | """
HTTP Scope Compliance Tests
Tests ASGI 3.0 HTTP scope compliance across frameworks.
"""
import pytest
from frameworks.contract import ASGI_HTTP_SCOPE_REQUIRED_KEYS
pytestmark = pytest.mark.http
class TestHttpScopeBasics:
"""Test basic HTTP scope attributes."""
async def test_scope_endpoint_returns_j... | 169 | 6,138 |
gunicorn | tests/docker/asgi_framework_compat/scripts/generate_grid.py | .py | #!/usr/bin/env python3
"""
Compatibility Grid Generator
Generates a compatibility matrix showing test results for each
ASGI framework tested with gunicorn's native ASGI worker.
"""
import json
import os
from datetime import datetime
from pathlib import Path
# Framework configuration
FRAMEWORKS = ["django", "fastapi... | 199 | 5,466 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/contract.py | .py | """
ASGI Framework Contract Definition
This module defines the required endpoints that each framework must implement
for compatibility testing with gunicorn's ASGI worker.
"""
# HTTP Endpoints Contract
HTTP_ENDPOINTS = {
"health": {
"path": "/health",
"method": "GET",
"description": "Healt... | 144 | 3,567 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/starlette_app/app.py | .py | """
Starlette ASGI Application for Compatibility Testing
Implements the contract endpoints for ASGI 3.0 compliance testing.
"""
import asyncio
import json
import sys
import traceback
from contextlib import asynccontextmanager
from typing import Any
from starlette.applications import Starlette
from starlette.response... | 285 | 8,629 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/fastapi_app/app.py | .py | """
FastAPI ASGI Application for Compatibility Testing
Implements the contract endpoints for ASGI 3.0 compliance testing.
"""
import asyncio
import json
import sys
import traceback
from contextlib import asynccontextmanager
from typing import Any
from fastapi import FastAPI, Request, WebSocket, WebSocketDisconnect
f... | 264 | 7,908 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/quart_app/app.py | .py | """
Quart ASGI Application for Compatibility Testing
Implements the contract endpoints for ASGI 3.0 compliance testing.
Quart is a Flask-like async framework built on ASGI.
"""
import asyncio
import json
import time
from quart import Quart, request, websocket, Response, make_response
app = Quart(__name__)
# Lifes... | 212 | 5,716 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py | .py | """
Litestar ASGI Application for Compatibility Testing
Implements the contract endpoints for ASGI 3.0 compliance testing.
Litestar is a modern ASGI framework with extensive feature support.
"""
import asyncio
import json
import time
from typing import Any, Dict
from litestar import Litestar, Request, get, post
from... | 255 | 7,366 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/blacksheep_app/app.py | .py | """
BlackSheep ASGI Application for Compatibility Testing
Implements the contract endpoints for ASGI 3.0 compliance testing.
BlackSheep is a high-performance ASGI framework.
"""
import asyncio
import json
import time
from typing import Any
from blacksheep import Application, Request, WebSocket, StreamedContent, Cont... | 228 | 6,835 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/asgi.py | .py | """
ASGI config for Django compatibility testing.
"""
import os
import time
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
import django
django.setup()
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from routing import websocket_urlpatterns
... | 61 | 1,754 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/views.py | .py | """
Django views for ASGI compatibility testing.
"""
import asyncio
import json
from django.http import (
HttpRequest,
HttpResponse,
JsonResponse,
StreamingHttpResponse,
)
from django.views.decorators.csrf import csrf_exempt
def serialize_scope(scope: dict) -> dict:
"""Convert ASGI scope to JSON... | 135 | 4,324 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/urls.py | .py | """
URL configuration for Django compatibility testing.
"""
from django.urls import path
from views import (
health,
scope_view,
echo,
headers_view,
status_view,
streaming_view,
sse_view,
large_view,
delay_view,
lifespan_state_view,
lifespan_counter_view,
)
urlpatterns = [
... | 33 | 893 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/settings.py | .py | """
Django settings for ASGI compatibility testing.
"""
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-test-key-for-asgi-compat"
# SECURI... | 49 | 1,036 |
gunicorn | tests/docker/asgi_framework_compat/frameworks/django_app/consumers.py | .py | """
Django Channels WebSocket consumers for ASGI compatibility testing.
"""
import json
from channels.generic.websocket import AsyncWebsocketConsumer
def serialize_scope(scope: dict) -> dict:
"""Convert ASGI scope to JSON-serializable dict."""
result = {}
for key, value in scope.items():
if key =... | 111 | 3,138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.