def setup_testing_defaults(environ):
 environ.setdefault('SERVER_NAME', '127.0.0.1')
 environ.setdefault('SERVER_PROTOCOL', 'HTTP/1.0')
 environ.setdefault('HTTP_HOST', environ['SERVER_NAME'])
 environ.setdefault('REQUEST_METHOD', 'GET')
 if (('SCRIPT_NAME' not in environ) and ('PATH_INFO' not in environ)):
  environ.setdefault('SCRIPT_NAME', '')
  environ.setdefault('PATH_INFO', '/')
 environ.setdefault('wsgi.version', (1, 0))
 environ.setdefault('wsgi.run_once', 0)
 environ.setdefault('wsgi.multithread', 0)
 environ.setdefault('wsgi.multiprocess', 0)
 from StringIO import StringIO
 environ.setdefault('wsgi.input', StringIO(''))
 environ.setdefault('wsgi.errors', StringIO())
 environ.setdefault('wsgi.url_scheme', guess_scheme(environ))
 if (environ['wsgi.url_scheme'] == 'http'):
  environ.setdefault('SERVER_PORT', '80')
 elif (environ['wsgi.url_scheme'] == 'https'):
  environ.setdefault('SERVER_PORT', '443')

def setup_testing_defaults ( environ ) : environ . setdefault ( 'SERVER_NAME' , '127.0.0.1' ) environ . setdefault ( 'SERVER_PROTOCOL' , 'HTTP/1.0' ) environ . setdefault ( 'HTTP_HOST' , environ [ 'SERVER_NAME' ] ) environ . setdefault ( 'REQUEST_METHOD' , 'GET' ) if ( ( 'SCRIPT_NAME' not in environ ) and ( 'PATH_INFO' not in environ ) ) : environ . setdefault ( 'SCRIPT_NAME' , '' ) environ . setdefault ( 'PATH_INFO' , '/' ) environ . setdefault ( 'wsgi.version' , ( 1 , 0 ) ) environ . setdefault ( 'wsgi.run_once' , 0 ) environ . setdefault ( 'wsgi.multithread' , 0 ) environ . setdefault ( 'wsgi.multiprocess' , 0 ) from StringIO import StringIO environ . setdefault ( 'wsgi.input' , StringIO ( '' ) ) environ . setdefault ( 'wsgi.errors' , StringIO ( ) ) environ . setdefault ( 'wsgi.url_scheme' , guess_scheme ( environ ) ) if ( environ [ 'wsgi.url_scheme' ] == 'http' ) : environ . setdefault ( 'SERVER_PORT' , '80' ) elif ( environ [ 'wsgi.url_scheme' ] == 'https' ) : environ . setdefault ( 'SERVER_PORT' , '443' )
update environ with trivial defaults for testing purposes this adds various parameters required for wsgi .