| 442 | |
| 443 | |
| 444 | def 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) |