diff --git a/cheroot/test/_pytest_plugin.py b/cheroot/test/_pytest_plugin.py index 1f1025d2a1..fa311241f6 100644 --- a/cheroot/test/_pytest_plugin.py +++ b/cheroot/test/_pytest_plugin.py @@ -11,19 +11,28 @@ 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): + 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 - ] + # pytest>=6.2.0 under Python 3.8: + # Refs: + # * https://docs.pytest.org/en/stable/usage.html#unraisable + # * https://github.com/pytest-dev/pytest/issues/5299 + early_config._inicache['filterwarnings'].extend(( + 'ignore:Exception in thread CP Server Thread-:' + 'pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception', + 'ignore:Exception in thread Thread-:' + 'pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception', + 'ignore:Exception ignored in. ' + ':' + 'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception', + 'ignore:Exception ignored in. ' + ':' + 'pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception', + )) diff --git a/pytest.ini b/pytest.ini index 11c557160a..d64e4c255c 100644 --- a/pytest.ini +++ b/pytest.ini @@ -33,14 +33,6 @@ doctest_optionflags = ALLOW_UNICODE ELLIPSIS filterwarnings = error - # pytest>=6.2.0 under Python 3.8: - # Ref: https://docs.pytest.org/en/stable/usage.html#unraisable - # Ref: https://github.com/pytest-dev/pytest/issues/5299 - ignore:Exception in thread CP Server Thread-:pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception - ignore:Exception in thread Thread-:pytest.PytestUnhandledThreadExceptionWarning:_pytest.threadexception - ignore:Exception ignored in. :pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception - ignore:Exception ignored in. :pytest.PytestUnraisableExceptionWarning:_pytest.unraisableexception - # cryptography==3.0 warning: # `cryptography.utils.CryptographyDeprecationWarning` happens but we # cannot import it because of the chicken-egg nature of its