``pytest.warns`` and similar functions now capture warnings when an exception is raised inside a ``with`` block.