When using wsgiref.util.setup_testing_defaults() to set up a WSGI environ is it possible to set the wsgi.input value so that one can test HTTP POST requests?
Investigating the wsgi.input value created by setup_testing_defaults() shows that it's a wsgi.validate.InputWrapper object with read, readline, readlines, input, close, and __iter__ methods, but no write开发者_JS百科 methods.
Edit:
I'm working on Python 2.6.1According to the WSGI spec, the wsgi.input is just a file-like object. So even if your helper library assigns some weird object to the environ['wsgi.input'], you may replace it with any file-like object you want. In particular, with a StringIO object:
e = {}
setup_testing_defaults(e)
s = urlencode({'q': 'is there a way to set the value of wsgi input'})
e['wsgi.input'] = StringIO(s)
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论