@contextmanager
def set_flask_request(wsgi_environ):
 environ = {}
 environ.update(wsgi_environ)
 wsgiref.util.setup_testing_defaults(environ)
 r = werkzeug.wrappers.Request(environ)
 with mock.patch.dict(extract_params.__globals__, {'request': r}):
  (yield)

@ contextmanager def set_flask_request ( wsgi_environ ) : environ = { } environ . update ( wsgi_environ ) wsgiref . util . setup_testing_defaults ( environ ) r = werkzeug . wrappers . Request ( environ ) with mock . patch . dict ( extract_params . __globals__ , { 'request' : r } ) : ( yield )
test helper context manager that mocks the flask request global i didnt need the whole request context just to test the functions in helpers and i wanted to be able to set the raw wsgi environment .