~ubuntu-branches/ubuntu/trusty/python-eventlet/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/wsgi_test.py

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2010-09-28 21:20:32 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100928212032-c4n67olxdoqzygmt
Tags: 0.9.12-0ubuntu1
New upstream release. (FFe: LP: #645899)

Show diffs side-by-side

added added

removed removed

Lines of Context:
924
924
        self.assertEqual(read_content.wait(), 'ok')
925
925
        self.assert_(blew_up[0])
926
926
 
 
927
    def test_exceptions_close_connection(self):
 
928
        def wsgi_app(environ, start_response):
 
929
            raise RuntimeError("intentional error")
 
930
        self.site.application = wsgi_app
 
931
        sock = eventlet.connect(('localhost', self.port))
 
932
        fd = sock.makefile('rw')
 
933
        fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n')
 
934
        fd.flush()
 
935
        response_line, headers, body = read_http(sock)
 
936
        self.assert_(response_line.startswith('HTTP/1.1 500 Internal Server Error'))
 
937
        self.assertEqual(headers['connection'], 'close')
 
938
        self.assert_('transfer-encoding' not in headers)
 
939
 
 
940
    def test_unicode_raises_error(self):
 
941
        def wsgi_app(environ, start_response):
 
942
            start_response("200 OK", [])
 
943
            yield u"oh hai"
 
944
            yield u"non-encodable unicode: \u0230"
 
945
        self.site.application = wsgi_app
 
946
        sock = eventlet.connect(('localhost', self.port))
 
947
        fd = sock.makefile('rw')
 
948
        fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
 
949
        fd.flush()
 
950
        response_line, headers, body = read_http(sock)
 
951
        self.assert_(response_line.startswith('HTTP/1.1 500 Internal Server Error'))
 
952
        self.assertEqual(headers['connection'], 'close')
 
953
        self.assert_('unicode' in body)
 
954
 
927
955
def read_headers(sock):
928
956
    fd = sock.makefile()
929
957
    try: