File tree Expand file tree Collapse file tree
tests/integrations/falcon Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,13 +206,20 @@ def _patch_prepare_middleware():
206206 original_prepare_middleware = falcon_helpers .prepare_middleware
207207
208208 def sentry_patched_prepare_middleware (
209- middleware = None , independent_middleware = False
209+ middleware = None , independent_middleware = False , asgi = False
210210 ):
211- # type: (Any, Any) -> Any
211+ # type: (Any, Any, bool) -> Any
212+ if asgi :
213+ # We don't support ASGI Falcon apps, so we don't patch anything here
214+ return original_prepare_middleware (middleware , independent_middleware , asgi )
215+
212216 hub = Hub .current
213217 integration = hub .get_integration (FalconIntegration )
214218 if integration is not None :
215219 middleware = [SentryFalconMiddleware ()] + (middleware or [])
220+
221+ # We intentionally omit the asgi argument here, since the default is False anyways,
222+ # and this way, we remain backwards-compatible with pre-3.0.0 Falcon versions.
216223 return original_prepare_middleware (middleware , independent_middleware )
217224
218225 falcon_helpers .prepare_middleware = sentry_patched_prepare_middleware
Original file line number Diff line number Diff line change 1313from sentry_sdk .integrations .logging import LoggingIntegration
1414
1515
16+ try :
17+ import falcon .asgi
18+ except ImportError :
19+ pass
20+ else :
21+ import falcon .inspect # We only need this module for the ASGI test
22+
23+
1624@pytest .fixture
1725def make_app (sentry_init ):
1826 def inner ():
@@ -391,3 +399,24 @@ def generator():
391399
392400 with sentry_sdk .configure_scope () as scope :
393401 assert not scope ._tags ["request_data" ]
402+
403+
404+ @pytest .mark .skipif (
405+ not hasattr (falcon , "asgi" ), reason = "This Falcon version lacks ASGI support."
406+ )
407+ def test_falcon_not_breaking_asgi (sentry_init ):
408+ """
409+ This test simply verifies that the Falcon integration does not break ASGI
410+ Falcon apps.
411+
412+ The test does not verify ASGI Falcon support, since our Falcon integration
413+ currently lacks support for ASGI Falcon apps.
414+ """
415+ sentry_init (integrations = [FalconIntegration ()])
416+
417+ asgi_app = falcon .asgi .App ()
418+
419+ try :
420+ falcon .inspect .inspect_app (asgi_app )
421+ except TypeError :
422+ pytest .fail ("Falcon integration causing errors in ASGI apps." )
You can’t perform that action at this time.
0 commit comments