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

Function pytest_runtest_setup

lib/sqlalchemy/testing/plugin/pytestplugin.py:444–468  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

442
443
444def pytest_runtest_setup(item):
445 from sqlalchemy.testing import asyncio
446
447 # pytest_runtest_setup runs *before* pytest fixtures with scope="class".
448 # plugin_base.start_test_class_outside_fixtures may opt to raise SkipTest
449 # for the whole class and has to run things that are across all current
450 # databases, so we run this outside of the pytest fixture system altogether
451 # and ensure asyncio greenlet if any engines are async
452
453 global _current_class, _current_warning_context
454
455 if isinstance(item, pytest.Function) and _current_class is None:
456 asyncio._maybe_async_provisioning(
457 plugin_base.start_test_class_outside_fixtures,
458 item.cls,
459 )
460 _current_class = item.getparent(pytest.Class)
461
462 if hasattr(_current_class.cls, "__warnings__"):
463 import warnings
464
465 _current_warning_context = warnings.catch_warnings()
466 _current_warning_context.__enter__()
467 for warning_message in _current_class.cls.__warnings__:
468 warnings.filterwarnings("ignore", warning_message)
469
470
471@pytest.hookimpl(hookwrapper=True)

Callers

nothing calls this directly

Calls 1

__enter__Method · 0.45

Tested by

no test coverage detected