Tests: more Python tests.
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import atexit
|
||||
|
||||
def application(environ, start_response):
|
||||
test_dir = environ.get('HTTP_TEST_DIR')
|
||||
def at_exit():
|
||||
environ['wsgi.errors'].write('At exit called.')
|
||||
|
||||
def create_file():
|
||||
open(test_dir + '/atexit', 'w')
|
||||
|
||||
atexit.register(create_file)
|
||||
atexit.register(at_exit)
|
||||
|
||||
start_response('200', [('Content-Length', '0')])
|
||||
return []
|
||||
|
||||
3
test/python/body_array/wsgi.py
Normal file
3
test/python/body_array/wsgi.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def application(env, start_response):
|
||||
start_response('200', [('Content-Length', '10')])
|
||||
return [b'0123', b'4567', b'89']
|
||||
6
test/python/body_io/wsgi.py
Normal file
6
test/python/body_io/wsgi.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import io
|
||||
|
||||
def application(env, start_response):
|
||||
start_response('200', [('Content-Length', '10')])
|
||||
f = io.BytesIO(b'0123456789')
|
||||
return f
|
||||
1
test/python/body_io_file/file
Normal file
1
test/python/body_io_file/file
Normal file
@@ -0,0 +1 @@
|
||||
body
|
||||
4
test/python/body_io_file/wsgi.py
Normal file
4
test/python/body_io_file/wsgi.py
Normal file
@@ -0,0 +1,4 @@
|
||||
def application(env, start_response):
|
||||
start_response('200', [('Content-Length', '5')])
|
||||
f = open('file', 'rb')
|
||||
return f
|
||||
10
test/python/close/wsgi.py
Normal file
10
test/python/close/wsgi.py
Normal file
@@ -0,0 +1,10 @@
|
||||
class application:
|
||||
def __init__(self, environ, start_response):
|
||||
self.environ = environ
|
||||
self.start = start_response
|
||||
|
||||
def __iter__(self):
|
||||
self.start('200', [(('Content-Length', '0'))])
|
||||
|
||||
def close(self):
|
||||
self.environ['wsgi.errors'].write('Close called.')
|
||||
10
test/python/close_error/wsgi.py
Normal file
10
test/python/close_error/wsgi.py
Normal file
@@ -0,0 +1,10 @@
|
||||
class application:
|
||||
def __init__(self, environ, start_response):
|
||||
self.environ = environ
|
||||
self.start = start_response
|
||||
|
||||
def __iter__(self):
|
||||
self.start('200', [(('!', '0'))])
|
||||
|
||||
def close(self):
|
||||
self.environ['wsgi.errors'].write('Close called.')
|
||||
5
test/python/errors_write/wsgi.py
Normal file
5
test/python/errors_write/wsgi.py
Normal file
@@ -0,0 +1,5 @@
|
||||
def application(environ, start_response):
|
||||
environ['wsgi.errors'].write('Error in application.')
|
||||
|
||||
start_response('200', [('Content-Length', '0')])
|
||||
return []
|
||||
5
test/python/input_iter/wsgi.py
Normal file
5
test/python/input_iter/wsgi.py
Normal file
@@ -0,0 +1,5 @@
|
||||
def application(environ, start_response):
|
||||
body = bytes(environ['wsgi.input'].__iter__())
|
||||
|
||||
start_response('200', [('Content-Length', str(len(body)))])
|
||||
return [body]
|
||||
7
test/python/input_read_length/wsgi.py
Normal file
7
test/python/input_read_length/wsgi.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def application(environ, start_response):
|
||||
|
||||
input_length = int(environ.get('HTTP_INPUT_LENGTH'))
|
||||
body = bytes(environ['wsgi.input'].read(input_length))
|
||||
|
||||
start_response('200', [('Content-Length', str(len(body)))])
|
||||
return [body]
|
||||
4
test/python/start_response_exit/wsgi.py
Normal file
4
test/python/start_response_exit/wsgi.py
Normal file
@@ -0,0 +1,4 @@
|
||||
def application(env, start_response):
|
||||
start_response('200', [('Content-Length', '1')])
|
||||
exit()
|
||||
return [b'X']
|
||||
3
test/python/syntax_error/wsgi.py
Normal file
3
test/python/syntax_error/wsgi.py
Normal file
@@ -0,0 +1,3 @@
|
||||
def application(env, start_response)
|
||||
start_response('200', [('Content-Length', '0')])
|
||||
return []
|
||||
@@ -10,6 +10,11 @@ def application(environ, start_response):
|
||||
('Request-Uri', environ.get('REQUEST_URI')),
|
||||
('Http-Host', environ.get('HTTP_HOST')),
|
||||
('Server-Protocol', environ.get('SERVER_PROTOCOL')),
|
||||
('Custom-Header', environ.get('HTTP_CUSTOM_HEADER'))
|
||||
('Custom-Header', environ.get('HTTP_CUSTOM_HEADER')),
|
||||
('Wsgi-Version', str(environ['wsgi.version'])),
|
||||
('Wsgi-Url-Scheme', environ['wsgi.url_scheme']),
|
||||
('Wsgi-Multithread', str(environ['wsgi.multithread'])),
|
||||
('Wsgi-Multiprocess', str(environ['wsgi.multiprocess'])),
|
||||
('Wsgi-Run-Once', str(environ['wsgi.run_once']))
|
||||
])
|
||||
return [body]
|
||||
|
||||
Reference in New Issue
Block a user