New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit testing when using request.body fails with KeyError: 'wsgi.input' #727
Comments
How about: with open('my_sample_input.txt') as f:
request.body = f
blah("booooo!")
|
Same result I'm afraid. Thank you for the suggestion though. |
The referenced pull request demonstrates the way to get unit tests of routes that need the request body working. For the lazy/googlers, here's how to do it (referencing the route definition above):
Essentially, you have to fake the relevant request headers and provide a IO object that can be iterated over un the bottle request parsing. |
util that implements this faking: boddle |
When unit testing a bottle py route function:
The following exception is raised:
The code will work if running as a server via bottle's run function, it's purely when I call it as a normal Python function e.g. in a unit test that the exception is raised.
Being able to unit test the individual route functions is very useful, but I'm a bit stumped on this one.
The text was updated successfully, but these errors were encountered: