Skip to content

Commit

Permalink
Add fixture for simple WSGI server. Ref #263.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 4, 2020
1 parent 73767a9 commit 5d4f1ca
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cheroot/test/test_wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Test wsgi."""

import threading

import pytest
import portend

from cheroot import wsgi


@pytest.fixture
def simple_wsgi_server():
"""Fucking simple wsgi server fixture (duh)."""
port = portend.find_available_local_port()

def app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [b'Hello world!']

host = '::'
addr = host, port
server = wsgi.Server(addr, app)
thread = threading.Thread(target=server.start)
thread.setDaemon(True)
thread.start()
yield locals()
# would prefer to stop server, but has errors
# server.stop()


def test_connection_keepalive(simple_wsgi_server):
"""Test the connection keepalive works (duh)."""
pass
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ testing =
# It's a transitive dependency of pytest-watch plugin.
colorama!=0.4.2; python_version == "3.4"

portend

[options.entry_points]
console_scripts =
cheroot = cheroot.cli:main

0 comments on commit 5d4f1ca

Please sign in to comment.