MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / pytest_runtest_setup

Function pytest_runtest_setup

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

__enter__Method · 0.45

Tested by

no test coverage detected