diff options
author | Miro Hron?ok <miro@hroncok.cz> | 2018-06-08 18:49:42 +0200 |
---|---|---|
committer | Miro Hron?ok <miro@hroncok.cz> | 2018-06-08 18:49:42 +0200 |
commit | bb9bdf7e5b5cb0d3458242c5b8ba6134efb282a4 (patch) | |
tree | e3f03e7ce1f234e0c91075da6d0b56040f693162 /tests/test_httpserver.py | |
download | paste-git-bb9bdf7e5b5cb0d3458242c5b8ba6134efb282a4.tar.gz |
Don't raise StopIteration from generator, return instead
See https://www.python.org/dev/peps/pep-0479/
Diffstat (limited to 'tests/test_httpserver.py')
-rw-r--r-- | tests/test_httpserver.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_httpserver.py b/tests/test_httpserver.py new file mode 100644 index 0000000..3d72c79 --- /dev/null +++ b/tests/test_httpserver.py @@ -0,0 +1,45 @@ +import email + +from paste.httpserver import WSGIHandler +from six.moves import StringIO + + +class MockServer(object): + server_address = ('127.0.0.1', 80) + + +class MockSocket(object): + def makefile(self, mode, bufsize): + return StringIO() + + +def test_environ(): + mock_socket = MockSocket() + mock_client_address = '1.2.3.4' + mock_server = MockServer() + + wsgi_handler = WSGIHandler(mock_socket, mock_client_address, mock_server) + wsgi_handler.command = 'GET' + wsgi_handler.path = '/path' + wsgi_handler.request_version = 'HTTP/1.0' + wsgi_handler.headers = email.message_from_string('Host: mywebsite') + + wsgi_handler.wsgi_setup() + + assert wsgi_handler.wsgi_environ['HTTP_HOST'] == 'mywebsite' + + +def test_environ_with_multiple_values(): + mock_socket = MockSocket() + mock_client_address = '1.2.3.4' + mock_server = MockServer() + + wsgi_handler = WSGIHandler(mock_socket, mock_client_address, mock_server) + wsgi_handler.command = 'GET' + wsgi_handler.path = '/path' + wsgi_handler.request_version = 'HTTP/1.0' + wsgi_handler.headers = email.message_from_string('Host: host1\nHost: host2') + + wsgi_handler.wsgi_setup() + + assert wsgi_handler.wsgi_environ['HTTP_HOST'] == 'host1,host2' |