-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixture for simple WSGI server. Ref #263.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters