1
1
from unittest import mock
2
2
3
3
import sentry_sdk
4
- from sentry_sdk .sessions import auto_session_tracking , track_session
4
+ from sentry_sdk .sessions import track_session
5
5
6
6
7
7
def sorted_aggregates (item ):
@@ -83,47 +83,6 @@ def test_aggregates(sentry_init, capture_envelopes):
83
83
assert aggregates [0 ]["errored" ] == 1
84
84
85
85
86
- def test_aggregates_deprecated (
87
- sentry_init , capture_envelopes , suppress_deprecation_warnings
88
- ):
89
- sentry_init (
90
- release = "fun-release" ,
91
- environment = "not-fun-env" ,
92
- )
93
- envelopes = capture_envelopes ()
94
-
95
- with auto_session_tracking (session_mode = "request" ):
96
- with sentry_sdk .new_scope () as scope :
97
- try :
98
- scope .set_user ({"id" : "42" })
99
- raise Exception ("all is wrong" )
100
- except Exception :
101
- sentry_sdk .capture_exception ()
102
-
103
- with auto_session_tracking (session_mode = "request" ):
104
- pass
105
-
106
- sentry_sdk .get_isolation_scope ().start_session (session_mode = "request" )
107
- sentry_sdk .get_isolation_scope ().end_session ()
108
- sentry_sdk .flush ()
109
-
110
- assert len (envelopes ) == 2
111
- assert envelopes [0 ].get_event () is not None
112
-
113
- sess = envelopes [1 ]
114
- assert len (sess .items ) == 1
115
- sess_event = sess .items [0 ].payload .json
116
- assert sess_event ["attrs" ] == {
117
- "release" : "fun-release" ,
118
- "environment" : "not-fun-env" ,
119
- }
120
-
121
- aggregates = sorted_aggregates (sess_event )
122
- assert len (aggregates ) == 1
123
- assert aggregates [0 ]["exited" ] == 2
124
- assert aggregates [0 ]["errored" ] == 1
125
-
126
-
127
86
def test_aggregates_explicitly_disabled_session_tracking_request_mode (
128
87
sentry_init , capture_envelopes
129
88
):
@@ -157,38 +116,6 @@ def test_aggregates_explicitly_disabled_session_tracking_request_mode(
157
116
assert "errored" not in aggregates [0 ]
158
117
159
118
160
- def test_aggregates_explicitly_disabled_session_tracking_request_mode_deprecated (
161
- sentry_init , capture_envelopes , suppress_deprecation_warnings
162
- ):
163
- sentry_init (
164
- release = "fun-release" , environment = "not-fun-env" , auto_session_tracking = False
165
- )
166
- envelopes = capture_envelopes ()
167
-
168
- with auto_session_tracking (session_mode = "request" ):
169
- with sentry_sdk .new_scope ():
170
- try :
171
- raise Exception ("all is wrong" )
172
- except Exception :
173
- sentry_sdk .capture_exception ()
174
-
175
- with auto_session_tracking (session_mode = "request" ):
176
- pass
177
-
178
- sentry_sdk .get_isolation_scope ().start_session (session_mode = "request" )
179
- sentry_sdk .get_isolation_scope ().end_session ()
180
- sentry_sdk .flush ()
181
-
182
- sess = envelopes [1 ]
183
- assert len (sess .items ) == 1
184
- sess_event = sess .items [0 ].payload .json
185
-
186
- aggregates = sorted_aggregates (sess_event )
187
- assert len (aggregates ) == 1
188
- assert aggregates [0 ]["exited" ] == 1
189
- assert "errored" not in aggregates [0 ]
190
-
191
-
192
119
def test_no_thread_on_shutdown_no_errors (sentry_init ):
193
120
sentry_init (
194
121
release = "fun-release" ,
@@ -214,31 +141,3 @@ def test_no_thread_on_shutdown_no_errors(sentry_init):
214
141
sentry_sdk .get_isolation_scope ().start_session (session_mode = "request" )
215
142
sentry_sdk .get_isolation_scope ().end_session ()
216
143
sentry_sdk .flush ()
217
-
218
-
219
- def test_no_thread_on_shutdown_no_errors_deprecated (
220
- sentry_init , suppress_deprecation_warnings
221
- ):
222
- sentry_init (
223
- release = "fun-release" ,
224
- environment = "not-fun-env" ,
225
- )
226
-
227
- # make it seem like the interpreter is shutting down
228
- with mock .patch (
229
- "threading.Thread.start" ,
230
- side_effect = RuntimeError ("can't create new thread at interpreter shutdown" ),
231
- ):
232
- with auto_session_tracking (session_mode = "request" ):
233
- with sentry_sdk .new_scope ():
234
- try :
235
- raise Exception ("all is wrong" )
236
- except Exception :
237
- sentry_sdk .capture_exception ()
238
-
239
- with auto_session_tracking (session_mode = "request" ):
240
- pass
241
-
242
- sentry_sdk .get_isolation_scope ().start_session (session_mode = "request" )
243
- sentry_sdk .get_isolation_scope ().end_session ()
244
- sentry_sdk .flush ()
0 commit comments