MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / our_warn

Function our_warn

lib/sqlalchemy/testing/assertions.py:218–246  ·  view source on GitHub ↗
(msg, *arg, **kw)

Source from the content-addressed store, hash-verified

216 real_warn = warnings.warn
217
218 def our_warn(msg, *arg, **kw):
219 if isinstance(msg, _EXC_CLS):
220 exception = type(msg)
221 msg = str(msg)
222 elif arg:
223 exception = arg[0]
224 else:
225 exception = None
226
227 if not exception or not issubclass(exception, _EXC_CLS):
228 if not squelch_other_warnings:
229 return real_warn(msg, *arg, **kw)
230 else:
231 return
232
233 if not filters and not raise_on_any_unexpected:
234 return
235
236 for filter_ in filters:
237 if (
238 (search_msg and filter_.search(msg))
239 or (regex and filter_.match(msg))
240 or (not regex and filter_ == msg)
241 ):
242 seen.discard(filter_)
243 break
244 else:
245 if not squelch_other_warnings:
246 real_warn(msg, *arg, **kw)
247
248 with mock.patch("warnings.warn", our_warn):
249 try:

Callers

nothing calls this directly

Calls 3

real_warnFunction · 0.85
matchMethod · 0.45
discardMethod · 0.45

Tested by

no test coverage detected