Skip to content

Commit

Permalink
Exclude invalid exceptions from filterwarnings
Browse files Browse the repository at this point in the history
Ref #355
  • Loading branch information
webknjaz committed Jan 5, 2021
1 parent 32aa821 commit 867360b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cheroot/test/_pytest_plugin.py
@@ -0,0 +1,29 @@
"""Local pytest plugin.
Contains hooks, which are tightly bound to the Cheroot framework
itself, useless for end-users' app testing.
"""

from __future__ import absolute_import, division, print_function
__metaclass__ = type

from pytest import __version__


pytest_version = tuple(map(int, __version__.split('.')))
unraisable_exceptions = {
('pytest', 'PytestUnhandledThreadExceptionWarning'),
('pytest', 'PytestUnraisableExceptionWarning'),
}


def pytest_load_initial_conftests(early_config, parser, args):
"""Drop unfilterable warning ignores."""
if pytest_version >= (6, 2, 0):
return

early_config._inicache['filterwarnings'] = [
fw for fw in early_config.getini('filterwarnings')
if fw.count(':') < 2 or
tuple(fw.split(':')[2].split('.')[:2]) not in unraisable_exceptions
]
3 changes: 3 additions & 0 deletions pytest.ini
Expand Up @@ -26,6 +26,9 @@ addopts =
--cov-report term-missing:skip-covered
--cov-report xml
# --cov-report xml:.test-results/pytest/cov.xml # alternatively move it here

# pre-load an in-tree plugin
-p cheroot.test._pytest_plugin
doctest_optionflags = ALLOW_UNICODE ELLIPSIS
filterwarnings =
error
Expand Down

0 comments on commit 867360b

Please sign in to comment.