diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index a3ac27837..5f776d440 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -36,7 +36,7 @@ jobs: env: PYTHONDEVMODE: "1" # -X dev PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding - PYTHONWARNINGS: "always" # -W always + PYTHONWARNINGS: "error,always:unclosed:ResourceWarning" PYTEST_ADDOPTS: "--cov ./ --cov-append --cov-config pyproject.toml" VIRTUALENV_SYSTEM_SITE_PACKAGES: "1" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a299029c9..ec7730c1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ env: FORCE_COLOR: "1" PYTHONDEVMODE: "1" # -X dev PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding - PYTHONWARNINGS: "always" # -W always + PYTHONWARNINGS: "error,always:unclosed:ResourceWarning" jobs: ubuntu: @@ -44,6 +44,8 @@ jobs: if: "endsWith(matrix.python, '-dev')" with: python-version: ${{ matrix.python }} + env: + PYTHONWARNINGS: "" - name: Check Python version run: python --version - name: Install graphviz @@ -52,6 +54,8 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install .[test] + env: + PYTHONWARNINGS: "" - name: Install Docutils ${{ matrix.docutils }} run: python -m pip install --upgrade "docutils==${{ matrix.docutils }}.*" - name: Test with pytest @@ -71,6 +75,8 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install .[test] + env: + PYTHONWARNINGS: "" - name: Test with pytest run: python -m pytest -vv --durations 25 @@ -92,7 +98,11 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install .[test] + env: + PYTHONWARNINGS: "" - name: Install Docutils' HEAD run: python -m pip install git+https://repo.or.cz/docutils.git\#subdirectory=docutils + env: + PYTHONWARNINGS: "" - name: Test with pytest run: python -m pytest -vv diff --git a/doc/internals/contributing.rst b/doc/internals/contributing.rst index a8753dddc..195f6a56c 100644 --- a/doc/internals/contributing.rst +++ b/doc/internals/contributing.rst @@ -181,7 +181,7 @@ of targets and allows testing against multiple different Python environments: * To run unit tests for a specific Python version and turn on deprecation warnings so they're shown in the test output:: - PYTHONWARNINGS=all tox -e py310 + PYTHONWARNINGS=error tox -e py310 * Arguments to ``pytest`` can be passed via ``tox``, e.g., in order to run a particular test:: diff --git a/tests/test_ext_napoleon_iterators.py b/tests/test_ext_napoleon_iterators.py index 7ecdb138d..a8357e4c6 100644 --- a/tests/test_ext_napoleon_iterators.py +++ b/tests/test_ext_napoleon_iterators.py @@ -3,8 +3,13 @@ import sys from unittest import TestCase +import pytest + from sphinx.deprecation import RemovedInSphinx70Warning -from sphinx.ext.napoleon.iterators import modify_iter, peek_iter + +with pytest.warns(DeprecationWarning, + match="sphinx.ext.napoleon.iterators is deprecated."): + from sphinx.ext.napoleon.iterators import modify_iter, peek_iter class ModuleIsDeprecatedTest(TestCase): diff --git a/tests/test_setup_command.py b/tests/test_setup_command.py index ef364676c..510515125 100644 --- a/tests/test_setup_command.py +++ b/tests/test_setup_command.py @@ -33,7 +33,7 @@ def setup_command(request, tempdir, rootdir): proc = subprocess.Popen( command, - env=dict(os.environ, PYTHONPATH=pythonpath), + env=dict(os.environ, PYTHONPATH=pythonpath, PYTHONWARNINGS='default'), stdout=subprocess.PIPE, stderr=subprocess.PIPE) yield namedtuple('setup', 'pkgroot,proc')(pkgrootdir, proc) diff --git a/tox.ini b/tox.ini index 487b07537..512aa5f74 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ description = extras = test setenv = - PYTHONWARNINGS = all + PYTHONWARNINGS = error PYTEST_ADDOPTS = {env:PYTEST_ADDOPTS:} --color yes commands= python -X dev -X warn_default_encoding -m pytest --durations 25 {posargs}