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

Function _apply_maybe_async

lib/sqlalchemy/testing/plugin/pytestplugin.py:374–403  ·  view source on GitHub ↗
(obj, recurse=True)

Source from the content-addressed store, hash-verified

372
373
374def _apply_maybe_async(obj, recurse=True):
375 from sqlalchemy.testing import asyncio
376
377 for name, value in vars(obj).items():
378 if (
379 (callable(value) or isinstance(value, classmethod))
380 and not getattr(value, "_maybe_async_applied", False)
381 and (name.startswith("test_"))
382 and not _is_wrapped_coroutine_function(value)
383 ):
384 is_classmethod = False
385 if isinstance(value, classmethod):
386 value = value.__func__
387 is_classmethod = True
388
389 @_pytest_fn_decorator
390 def make_async(fn, *args, **kwargs):
391 return asyncio._maybe_async(fn, *args, **kwargs)
392
393 do_async = make_async(value)
394 if is_classmethod:
395 do_async = classmethod(do_async)
396 do_async._maybe_async_applied = True
397
398 setattr(obj, name, do_async)
399 if recurse:
400 for cls in obj.mro()[1:]:
401 if cls != object:
402 _apply_maybe_async(cls, False)
403 return obj
404
405
406def _parametrize_cls(module, cls):

Callers 1

Calls 4

make_asyncFunction · 0.85
itemsMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected