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:
|
env:
|
||||||
PYTHONDEVMODE: "1" # -X dev
|
PYTHONDEVMODE: "1" # -X dev
|
||||||
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
|
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
|
||||||
PYTHONWARNINGS: "always" # -W always
|
PYTHONWARNINGS: "error,always:unclosed:ResourceWarning"
|
||||||
PYTEST_ADDOPTS: "--cov ./ --cov-append --cov-config pyproject.toml"
|
PYTEST_ADDOPTS: "--cov ./ --cov-append --cov-config pyproject.toml"
|
||||||
VIRTUALENV_SYSTEM_SITE_PACKAGES: "1"
|
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"
|
FORCE_COLOR: "1"
|
||||||
PYTHONDEVMODE: "1" # -X dev
|
PYTHONDEVMODE: "1" # -X dev
|
||||||
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
|
PYTHONWARNDEFAULTENCODING: "1" # -X warn_default_encoding
|
||||||
PYTHONWARNINGS: "always" # -W always
|
PYTHONWARNINGS: "error,always:unclosed:ResourceWarning"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ubuntu:
|
ubuntu:
|
||||||
@ -44,6 +44,8 @@ jobs:
|
|||||||
if: "endsWith(matrix.python, '-dev')"
|
if: "endsWith(matrix.python, '-dev')"
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python }}
|
python-version: ${{ matrix.python }}
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: ""
|
||||||
- name: Check Python version
|
- name: Check Python version
|
||||||
run: python --version
|
run: python --version
|
||||||
- name: Install graphviz
|
- name: Install graphviz
|
||||||
@ -52,6 +54,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install .[test]
|
python -m pip install .[test]
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: ""
|
||||||
- name: Install Docutils ${{ matrix.docutils }}
|
- name: Install Docutils ${{ matrix.docutils }}
|
||||||
run: python -m pip install --upgrade "docutils==${{ matrix.docutils }}.*"
|
run: python -m pip install --upgrade "docutils==${{ matrix.docutils }}.*"
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
@ -71,6 +75,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install .[test]
|
python -m pip install .[test]
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: ""
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: python -m pytest -vv --durations 25
|
run: python -m pytest -vv --durations 25
|
||||||
|
|
||||||
@ -92,7 +98,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
python -m pip install .[test]
|
python -m pip install .[test]
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: ""
|
||||||
- name: Install Docutils' HEAD
|
- name: Install Docutils' HEAD
|
||||||
run: python -m pip install git+https://repo.or.cz/docutils.git\#subdirectory=docutils
|
run: python -m pip install git+https://repo.or.cz/docutils.git\#subdirectory=docutils
|
||||||
|
env:
|
||||||
|
PYTHONWARNINGS: ""
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: python -m pytest -vv
|
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
|
* To run unit tests for a specific Python version and turn on deprecation
|
||||||
warnings so they're shown in the test output::
|
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
|
* Arguments to ``pytest`` can be passed via ``tox``, e.g., in order to run a
|
||||||
particular test::
|
particular test::
|
||||||
|
@ -3,8 +3,13 @@
|
|||||||
import sys
|
import sys
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from sphinx.deprecation import RemovedInSphinx70Warning
|
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):
|
class ModuleIsDeprecatedTest(TestCase):
|
||||||
|
@ -33,7 +33,7 @@ def setup_command(request, tempdir, rootdir):
|
|||||||
|
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
command,
|
command,
|
||||||
env=dict(os.environ, PYTHONPATH=pythonpath),
|
env=dict(os.environ, PYTHONPATH=pythonpath, PYTHONWARNINGS='default'),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
yield namedtuple('setup', 'pkgroot,proc')(pkgrootdir, proc)
|
yield namedtuple('setup', 'pkgroot,proc')(pkgrootdir, proc)
|
||||||
|
2
tox.ini
2
tox.ini
@ -21,7 +21,7 @@ description =
|
|||||||
extras =
|
extras =
|
||||||
test
|
test
|
||||||
setenv =
|
setenv =
|
||||||
PYTHONWARNINGS = all
|
PYTHONWARNINGS = error
|
||||||
PYTEST_ADDOPTS = {env:PYTEST_ADDOPTS:} --color yes
|
PYTEST_ADDOPTS = {env:PYTEST_ADDOPTS:} --color yes
|
||||||
commands=
|
commands=
|
||||||
python -X dev -X warn_default_encoding -m pytest --durations 25 {posargs}
|
python -X dev -X warn_default_encoding -m pytest --durations 25 {posargs}
|
||||||
|
Loading…
Reference in New Issue
Block a user