MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / our_warn

Function our_warn

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

real_warnFunction · 0.85
matchMethod · 0.45
discardMethod · 0.45

Tested by

no test coverage detected