1
1
import pytest
2
2
3
3
from tribler .core .sentry_reporter .sentry_tools import (
4
- _re_search_exception , delete_item ,
4
+ _re_search_exception , _re_search_exception_exclusions , delete_item ,
5
5
distinct_by ,
6
6
extract_dict ,
7
7
format_version ,
@@ -151,15 +151,27 @@ def test_extract_dict():
151
151
]
152
152
153
153
EXCEPTION_STRINGS = [
154
- ('OverflowError: bind(): port must be 0-65535' ,
155
- ('OverflowError' , 'bind(): port must be 0-65535' ),
156
- ),
157
-
158
- ("pony.orm.core.TransactionIntegrityError : MiscData['db_version'] cannot be stored. IntegrityError: UNIQUE" ,
159
- ('pony.orm.core.TransactionIntegrityError' , "MiscData['db_version'] cannot be stored. IntegrityError: UNIQUE" ),
160
- ),
161
-
162
- ('ERROR <exception_handler:100>' , None )
154
+ (
155
+ 'OverflowError: bind(): port must be 0-65535' ,
156
+ (
157
+ 'OverflowError' ,
158
+ 'bind(): port must be 0-65535'
159
+ ),
160
+ ),
161
+
162
+ (
163
+ "pony_orm.core.TransactionIntegrityError: MiscData['db_version'] cannot be stored. IntegrityError: UNIQUE" ,
164
+ (
165
+ 'pony_orm.core.TransactionIntegrityError' ,
166
+ "MiscData['db_version'] cannot be stored. IntegrityError: UNIQUE"
167
+ ),
168
+ ),
169
+
170
+ # Strings thst should not be matched
171
+ ('ERROR <exception_handler:100>' , None ),
172
+ ('PyInstaller\loader\pyimod03_importers.py:495' , None ),
173
+ ('foo:bar: baz' , None ),
174
+ ('foo<bar>: baz' , None ),
163
175
]
164
176
165
177
@@ -180,6 +192,18 @@ def test_parse_last_core_output_re(given, expected):
180
192
assert m == expected
181
193
182
194
195
+ EXCEPTION_EXCLUSIONS_STRINGS = [
196
+ 'UserWarning' ,
197
+ ]
198
+
199
+
200
+ @pytest .mark .parametrize ('given' , EXCEPTION_EXCLUSIONS_STRINGS )
201
+ def test_re_search_exception_exclusions (given ):
202
+ # Test that `_re_search_exception_exclusions` matches with the expected values from the
203
+ # `EXCEPTION_EXCLUSIONS_STRINGS`
204
+ assert _re_search_exception_exclusions .search (given )
205
+
206
+
183
207
def test_parse_last_core_output ():
184
208
# Test that `parse_last_core_output` correctly extract the last core exception from the real raw core output
185
209
@@ -211,3 +235,8 @@ def test_parse_last_core_output_no_match():
211
235
212
236
last_core_exception = parse_last_core_output ('last core output without exceptions' )
213
237
assert not last_core_exception
238
+
239
+
240
+ def test_parse_last_core_output_exclusion ():
241
+ last_core_exception = parse_last_core_output ('UserWarning: You are using cryptography on a 32-bit Python on a...' )
242
+ assert not last_core_exception
0 commit comments