diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1107089a6..071fdadba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,13 +18,10 @@ jobs: docutils: du16 - python: "3.9" docutils: du17 - coverage: "--cov ./ --cov-append --cov-config setup.cfg" - python: "3.10" docutils: du18 - python: "3.11-dev" docutils: py311 - env: - PYTEST_ADDOPTS: ${{ matrix.coverage }} steps: - uses: actions/checkout@v3 @@ -43,12 +40,9 @@ jobs: - name: Install graphviz run: sudo apt-get install graphviz - name: Install dependencies - run: python -m pip install -U pip tox codecov + run: python -m pip install -U pip tox - name: Run Tox run: tox -e ${{ matrix.docutils }} -- -vv - - name: codecov - uses: codecov/codecov-action@v1 - if: matrix.coverage windows: runs-on: windows-2019 @@ -62,3 +56,32 @@ jobs: run: python -m pip install -U pip tox - name: Run Tox run: tox -e py -- -vv + + coverage: + # only run on pushes to branches in the sphinx-doc/sphinx repo + if: github.repository_owner == 'sphinx-doc' && github.event_name == 'push' + runs-on: ubuntu-latest + env: + PYTEST_ADDOPTS: "--cov ./ --cov-append --cov-config setup.cfg" + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3 + uses: actions/setup-python@v3 + with: + python-version: 3 + + - name: Check Python version + run: python --version + + - name: Install graphviz + run: sudo apt-get install graphviz + + - name: Install dependencies + run: python -m pip install -U tox pip codecov pytest-cov + + - name: Run Tox + run: tox -e py -- -vv + + - name: codecov + uses: codecov/codecov-action@v3 diff --git a/setup.py b/setup.py index e11a894c7..4ec215697 100644 --- a/setup.py +++ b/setup.py @@ -47,8 +47,7 @@ extras_require = { "types-requests", ], 'test': [ - 'pytest', - 'pytest-cov', + 'pytest>=4.6', 'html5lib', "typed_ast; python_version < '3.8'", 'cython', diff --git a/sphinx/testing/fixtures.py b/sphinx/testing/fixtures.py index 0b558e32c..891f0f7cc 100644 --- a/sphinx/testing/fixtures.py +++ b/sphinx/testing/fixtures.py @@ -64,19 +64,14 @@ def app_params(request: Any, test_params: Dict, shared_result: SharedResult, # ##### process pytest.mark.sphinx - if hasattr(request.node, 'iter_markers'): # pytest-3.6.0 or newer - markers = request.node.iter_markers("sphinx") - else: - markers = request.node.get_marker("sphinx") pargs = {} kwargs: Dict[str, Any] = {} - if markers is not None: - # to avoid stacking positional args - for info in reversed(list(markers)): - for i, a in enumerate(info.args): - pargs[i] = a - kwargs.update(info.kwargs) + # to avoid stacking positional args + for info in reversed(list(request.node.iter_markers("sphinx"))): + for i, a in enumerate(info.args): + pargs[i] = a + kwargs.update(info.kwargs) args = [pargs[i] for i in sorted(pargs.keys())] @@ -113,10 +108,7 @@ def test_params(request: Any) -> Dict: have same 'shared_result' value. **NOTE**: You can not specify both shared_result and srcdir. """ - if hasattr(request.node, 'get_closest_marker'): # pytest-3.6.0 or newer - env = request.node.get_closest_marker('test_params') - else: - env = request.node.get_marker('test_params') + env = request.node.get_closest_marker('test_params') kwargs = env.kwargs if env else {} result = { 'shared_result': None, diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py index ee21f8ffd..2d427417b 100644 --- a/tests/test_ext_apidoc.py +++ b/tests/test_ext_apidoc.py @@ -22,18 +22,13 @@ def apidoc(rootdir, tempdir, apidoc_params): @pytest.fixture def apidoc_params(request): - if hasattr(request.node, 'iter_markers'): # pytest-3.6.0 or newer - markers = request.node.iter_markers("apidoc") - else: - markers = request.node.get_marker("apidoc") pargs = {} kwargs = {} - if markers is not None: - for info in reversed(list(markers)): - for i, a in enumerate(info.args): - pargs[i] = a - kwargs.update(info.kwargs) + for info in reversed(list(request.node.iter_markers("apidoc"))): + for i, a in enumerate(info.args): + pargs[i] = a + kwargs.update(info.kwargs) args = [pargs[i] for i in sorted(pargs.keys())] return args, kwargs diff --git a/tests/test_setup_command.py b/tests/test_setup_command.py index a56f9d4a3..ef364676c 100644 --- a/tests/test_setup_command.py +++ b/tests/test_setup_command.py @@ -18,10 +18,7 @@ def setup_command(request, tempdir, rootdir): Run `setup.py build_sphinx` with args and kwargs, pass it to the test and clean up properly. """ - if hasattr(request.node, 'get_closest_marker'): # pytest-3.6.0 or newer - marker = request.node.get_closest_marker('setup_command') - else: - marker = request.node.get_marker('setup_command') + marker = request.node.get_closest_marker('setup_command') args = marker.args if marker else [] pkgrootdir = tempdir / 'test-setup' diff --git a/tox.ini b/tox.ini index 74e255bc1..105a02597 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 2.4.0 -envlist = docs,flake8,mypy,twine,coverage,py{36,37,38,39,310},du{14,15,16,17,18} +envlist = docs,flake8,mypy,twine,py{36,37,38,39,310},du{14,15,16,17,18} [testenv] usedevelop = True @@ -58,16 +58,6 @@ extras = commands = isort --check-only --diff . -[testenv:coverage] -basepython = python3 -description = - Run code coverage checks. -setenv = - PYTEST_ADDOPTS = --cov sphinx --cov-config "{toxinidir}/setup.cfg" -commands = - {[testenv]commands} - coverage report - [testenv:mypy] basepython = python3 description =