@@ -147,7 +147,7 @@ def bar():
147147 foo ()
148148
149149 event , = events
150- thread , = event ["threads" ]
150+ thread , = event ["threads" ][ "values" ]
151151 functions = [x ["function" ] for x in thread ["stacktrace" ]["frames" ]]
152152 assert functions [- 2 :] == ["foo" , "bar" ]
153153
@@ -167,11 +167,26 @@ def bar():
167167 foo ()
168168
169169 event , = events
170- thread , = event ["threads" ]
170+ thread , = event ["threads" ][ "values" ]
171171 local_vars = [x .get ("vars" ) for x in thread ["stacktrace" ]["frames" ]]
172172 assert local_vars [- 2 :] == [None , None ]
173173
174174
175+ def test_attach_stacktrace_in_app (sentry_init , capture_events ):
176+ sentry_init (attach_stacktrace = True , in_app_exclude = ["_pytest" ])
177+ events = capture_events ()
178+
179+ capture_message ("hi" )
180+
181+ event , = events
182+ thread , = event ["threads" ]["values" ]
183+ frames = thread ["stacktrace" ]["frames" ]
184+ pytest_frames = [f for f in frames if f ["module" ].startswith ("_pytest" )]
185+ assert pytest_frames
186+ assert all (f ["in_app" ] is False for f in pytest_frames )
187+ assert any (f ["in_app" ] for f in frames )
188+
189+
175190def test_attach_stacktrace_disabled ():
176191 events = []
177192 hub = Hub (Client (attach_stacktrace = False , transport = events .append ))
0 commit comments