From 2ceec37662b7b053ca6ffc328d95ba838bf26a2b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 10 Nov 2021 17:17:18 -0500 Subject: [PATCH] Move warning suppression to pytest.ini so it occurs after 'error'. --- conftest.py | 22 ---------------------- pytest.ini | 12 ++++++++++++ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/conftest.py b/conftest.py index f82b939bd9..d5e851fe50 100644 --- a/conftest.py +++ b/conftest.py @@ -1,5 +1,4 @@ import sys -import warnings pytest_plugins = 'setuptools.tests.fixtures' @@ -28,24 +27,3 @@ def pytest_addoption(parser): if sys.version_info < (3, 6): collect_ignore.append('docs/conf.py') # uses f-strings collect_ignore.append('pavement.py') - - -if sys.version_info > (3, 10): - # https://github.com/pypa/setuptools/pull/2865#issuecomment-965700112 - warnings.filterwarnings( - 'ignore', - 'The distutils.sysconfig module is deprecated, use sysconfig instead', - ) - - -is_pypy = '__pypy__' in sys.builtin_module_names -if is_pypy: - # Workaround for pypa/setuptools#2868 - warnings.filterwarnings( - 'ignore', - 'Distutils was imported before setuptools', - ) - warnings.filterwarnings( - 'ignore', - 'Setuptools is replacing distutils', - ) diff --git a/pytest.ini b/pytest.ini index 2678afd846..df1c2af91d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -34,3 +34,15 @@ filterwarnings= # https://github.com/pypa/setuptools/issues/2497 ignore:.* is an invalid version and will not be supported::pkg_resources + + # https://github.com/pypa/setuptools/pull/2865#issuecomment-965700112 + # ideally would apply to Python 3.10+ when + # SETUPTOOLS_USE_DISTUTILS=stdlib but for + # https://github.com/pytest-dev/pytest/discussions/9296 + ignore:The distutils.sysconfig module is deprecated, use sysconfig instead + + # Workaround for pypa/setuptools#2868 + # ideally would apply to PyPy only but for + # https://github.com/pytest-dev/pytest/discussions/9296 + ignore:Distutils was imported before setuptools + ignore:Setuptools is replacing distutils