-
Notifications
You must be signed in to change notification settings - Fork 21
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
What's the best way to get the request object back? #25
Comments
Why do you need get request back from |
Also if you need to test the request obj itself, you can easily test it inside handler. |
One use case can be to test |
you can either async def test_func(app):
@app.route("/test_get", methods=['GET'])
async def test_get(request):
# test request session
test_cli = await test_client(app)
resp = await test_cli.get('/test_get') or make the route handler to return request["session"] for testing. |
I think it's not very convenient to have test code inside route handlers. Is there any particular reason you don't make use of Sanic's own test client? https://github.com/huge-success/sanic/blob/master/sanic/testing.py |
|
Cool! I appreciate your contribution to this repo and Sanic. Neat work! One more question, what do you think of maybe having a kwarg named:
|
Yeah, let me think about this. |
Just an idea, here's how I managed to preserve the most recent request: while setting up my app in my test fixtures, I included the following lines:
Now whenever I want to access the previous request, I do the following
|
I think it would be nice if there's an easy way to get the request object back from the test client. What do you think?
The text was updated successfully, but these errors were encountered: