Skip to content

Instantly share code, notes, and snippets.

@kgriffs
Created May 21, 2022 00:21
Show Gist options
  • Save kgriffs/253a340c7ea54637c34e1fbe94fbc7d5 to your computer and use it in GitHub Desktop.
Save kgriffs/253a340c7ea54637c34e1fbe94fbc7d5 to your computer and use it in GitHub Desktop.
Test a Falcon WSGI app directly using httpx
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