Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fef1f09
apply warnings filter as soon as possible, and remove it as late as p…
graingert Dec 13, 2024
229a64b
apply unraisablehook and threadexception before the warning plugin, s…
graingert Dec 13, 2024
10eb342
apply the warning filter during pytest_configure
graingert Dec 13, 2024
11714dd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 13, 2024
cc5b555
restore the filterwarnings marker config
graingert Dec 13, 2024
a3881db
move lsof warning to something ignorable and ignore it
graingert Dec 13, 2024
f37d07a
add newsfragment
graingert Dec 13, 2024
9a953f4
add test
graingert Dec 13, 2024
7581137
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 13, 2024
b32316c
simplify PytestFDWarning filter
graingert Dec 13, 2024
72475f4
fix PytestFDWarning module
graingert Dec 13, 2024
e2e81b2
get more patch coverage
graingert Dec 13, 2024
5349709
Merge branch 'main' into apply-warnings-filter-asap-remove-alap
graingert Dec 16, 2024
89ff09c
Merge branch 'main' into apply-warnings-filter-asap-remove-alap
graingert Dec 17, 2024
b5e00fb
Update changelog/10404.bugfix.rst
graingert Dec 17, 2024
a00679a
add more realistic create_task/unawaited coro warning test
graingert Dec 17, 2024
e828fa9
update comments
graingert Dec 17, 2024
003a51f
enable coverage on lsof tests
graingert Dec 17, 2024
808ad3d
ensure global warning filter application does not swallow default war…
graingert Dec 18, 2024
c5fb158
Update testing/test_unraisableexception.py
graingert Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
apply warnings filter as soon as possible, and remove it as late as p…
…ossible
  • Loading branch information
graingert committed Dec 13, 2024
commit fef1f09475c544c8bd26f0d417ced29d1d620d2b
11 changes: 10 additions & 1 deletion src/_pytest/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from contextlib import contextmanager, ExitStack
import sys
from typing import Literal
import warnings
Expand Down Expand Up @@ -131,3 +131,12 @@ def pytest_load_initial_conftests(
config=early_config, ihook=early_config.hook, when="config", item=None
):
return (yield)

def pytest_configure(config: Config) -> None:
with ExitStack() as stack:
stack.enter_context(
catch_warnings_for_item(
config=config, ihook=config.hook, when="config", item=None
)
)
config.add_cleanup(stack.pop_all().close)