Skip to content

How to make simulate_post work? #1969

Answered by vytas7
phbelitz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @phbelitz!
In order to simulate requests without going over the network, Falcon's test client uses wsgiref's machinery, which has some glitches in its input stream wrapper (you might observe a similar behavior using wsgiref.simple_server). This is discussed more in depth here: req.stream. See also: Why does req.stream.read() hang for certain requests?

In order to make your code work on any PEP-3333 compliant WSGI server regardless of the underlying implementation, you can instead use our req.bounded_stream wrapper, which works around the most common differences in WSGI input stream behavior.

The following passes for me:

import json

import falcon
import pytest
from falcon import testing

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@phbelitz
Comment options

Answer selected by phbelitz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants