Created
May 21, 2022 00:21
-
-
Save kgriffs/253a340c7ea54637c34e1fbe94fbc7d5 to your computer and use it in GitHub Desktop.
Test a Falcon WSGI app directly using httpx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import falcon | |
import httpx | |
class TestResource: | |
def on_get(self, req, resp): | |
raise falcon.HTTPTooManyRequests() | |
def test_a_thing(): | |
app = falcon.App() | |
app.add_route('/', TestResource()) | |
with httpx.Client(app=app, base_url='http://testserver') as client: | |
r = client.get('/') | |
assert r.status_code == 429 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment