@@ -12,6 +12,26 @@ def app(environ, start_response):
12
12
return app
13
13
14
14
15
+ @pytest .fixture
16
+ def crashing_env_modifing_app ():
17
+ class TooSmartClass (object ):
18
+ def __init__ (self , environ ):
19
+ self .environ = environ
20
+
21
+ def __repr__ (self ):
22
+ if "my_representation" in self .environ :
23
+ return self .environ ["my_representation" ]
24
+
25
+ self .environ ["my_representation" ] = "<This is me>"
26
+ return self .environ ["my_representation" ]
27
+
28
+ def app (environ , start_response ):
29
+ environ ["tsc" ] = TooSmartClass (environ )
30
+ 1 / 0
31
+
32
+ return app
33
+
34
+
15
35
def test_basic (sentry_init , crashing_app , capture_events ):
16
36
sentry_init (send_default_pii = True )
17
37
app = SentryWsgiMiddleware (crash
8E13
ing_app )
@@ -30,3 +50,15 @@ def test_basic(sentry_init, crashing_app, capture_events):
30
50
"query_string" : "" ,
31
51
"url" : "http://localhost/" ,
32
52
}
53
+
54
+
55
+ def test_env_modifing_app (sentry_init , crashing_env_modifing_app , capture_events ):
56
+ sentry_init (send_default_pii = True )
57
+ app = SentryWsgiMiddleware (crashing_env_modifing_app )
58
+ client = Client (app )
59
+ events = capture_events ()
60
+
61
+ with pytest .raises (ZeroDivisionError ):
62
+ client .get ("/" )
63
+
64
+ assert len (events ) == 1 # only one exception is raised
0 commit comments