mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Treat Python warnings as errors during testing
This commit is contained in:
parent
a502e75233
commit
c17300aa7a
2
.github/workflows/coverage.yml
vendored
2
.github/workflows/coverage.yml
vendored
@ -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"
|
||||
|
||||
|
12
.github/workflows/main.yml
vendored
12
.github/workflows/main.yml
vendored
@ -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
|
||||
|
@ -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::
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user