From 03c6b835a168f1fbf0a457ad8688834ee943c54f Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 18 Oct 2025 20:46:14 +0200 Subject: [PATCH 1/6] feat: add configuration for running tox with uv Acceptance test needed to be adjusted as test_stop_iteration_runtest_protocol triggers a different error message that seems to map to PEP-0479 when using a uv provided python environment. --- pyproject.toml | 20 ++++++++++---------- testing/acceptance_test.py | 21 ++++++++++++++++++--- tox-uv.ini | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 13 deletions(-) create mode 100644 tox-uv.ini diff --git a/pyproject.toml b/pyproject.toml index 091676409ed..2d3c09bcaaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,21 +47,21 @@ dynamic = [ ] dependencies = [ "colorama>=0.4; sys_platform=='win32'", - "exceptiongroup>=1; python_version<'3.11'", - "iniconfig>=1.0.1", + "exceptiongroup>=1.1; python_version<'3.11'", + "iniconfig>=2", "packaging>=22", "pluggy>=1.5,<2", - "pygments>=2.7.2", + "pygments>=2.14", "tomli>=1; python_version<'3.11'", ] optional-dependencies.dev = [ - "argcomplete", - "attrs>=19.2", - "hypothesis>=3.56", - "mock", - "requests", - "setuptools", - "xmlschema", + "argcomplete>=3.5", + "attrs>=21", + "hypothesis>=5", + "mock>=5", + "requests>=2.26", + "setuptools>=80", + "xmlschema>=3", ] urls.Changelog = "https://docs.pytest.org/en/stable/changelog.html" urls.Contact = "https://docs.pytest.org/en/stable/contact.html" diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index b9384008483..f5358168b32 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1642,12 +1642,27 @@ def test_fail_call(): result = pytester.runpytest() assert result.ret == ExitCode.TESTS_FAILED result.assert_outcomes(failed=1, passed=1, errors=2) + result.stdout.fnmatch_lines( [ "=* short test summary info =*", - "FAILED test_it.py::test_fail_call - StopIteration: 3", - "ERROR test_it.py::test_fail_setup - StopIteration: 1", - "ERROR test_it.py::test_fail_teardown - StopIteration: 2", "=* 1 failed, 1 passed, 2 errors in * =*", ] ) + + runtime_errors = { + "FAILED test_it.py::test_fail_call - RuntimeError: generator raised StopIteration", + "ERROR test_it.py::test_fail_setup - RuntimeError: generator raised StopIteration", + "ERROR test_it.py::test_fail_teardown - RuntimeError: generator raised StopIte...", + } + got_runtime_errors = runtime_errors.issubset(result.outlines) + + stopiteration_errors = { + "FAILED test_it.py::test_fail_call - StopIteration: 3", + "ERROR test_it.py::test_fail_setup - StopIteration: 1", + "ERROR test_it.py::test_fail_teardown - StopIteration: 2", + } + + got_stopiteration_errors = stopiteration_errors.issubset(result.outlines) + + assert got_runtime_errors or got_stopiteration_errors diff --git a/tox-uv.ini b/tox-uv.ini new file mode 100644 index 00000000000..386a270034a --- /dev/null +++ b/tox-uv.ini @@ -0,0 +1,28 @@ +[tox] +requires = + tox>=4 + tox-uv>=1 +isolated_build = True +distshare = {homedir}/.tox/uv-distshare +envlist = + py310 + +[testenv] +description = + run the tests + under `{basepython}` +uv_resolution = lowest-direct +uv_python_preference = only-managed +commands = + {env:_PYTEST_TOX_COVERAGE_RUN:} pytest {posargs:{env:_PYTEST_TOX_DEFAULT_POSARGS:}} --maxfail=1 --pdb +passenv = + PYTEST_ADDOPTS + TERM + SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST + CI +setenv = + _PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:} + +extras = dev +deps = + {env:_PYTEST_TOX_EXTRA_DEP:} From d9e087f9bda727801024429c7a332425c1a833cf Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 18 Oct 2025 21:27:25 +0200 Subject: [PATCH 2/6] feat: add test workflow using uv --- .github/workflows/test-uv.yml | 144 ++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 .github/workflows/test-uv.yml diff --git a/.github/workflows/test-uv.yml b/.github/workflows/test-uv.yml new file mode 100644 index 00000000000..0cf700ca2c4 --- /dev/null +++ b/.github/workflows/test-uv.yml @@ -0,0 +1,144 @@ +name: test uv + +on: + push: + branches: + - main + - "[0-9]+.[0-9]+.x" + - "test-me-*" + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" + + pull_request: + branches: + - main + - "[0-9]+.[0-9]+.x" + types: + - opened # default + - synchronize # default + - reopened # default + - ready_for_review # used in PRs created from the release workflow + + workflow_dispatch: # allows manual triggering of the workflow + +env: + PYTEST_ADDOPTS: "--color=yes" + +# Cancel running jobs for the same workflow and branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# Set permissions at the job level. +permissions: {} + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: false + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 + + build: + needs: [package] + + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + name: [ + "windows-py310", + + "ubuntu-py310", + + "macos-py310", + ] + + include: + - name: "windows-py310" + python: "3.10" + os: windows-latest + tox_env: "py310" + + - name: "ubuntu-py310" + python: "3.10" + os: ubuntu-latest + tox_env: "py310" + use_coverage: true + + - name: "macos-py310" + python: "3.10" + os: macos-latest + tox_env: "py310" + xfail: true + + continue-on-error: ${{ matrix.xfail && true || false }} + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Download Package + uses: actions/download-artifact@v5 + with: + name: Packages + path: dist + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python }} + check-latest: true + allow-prereleases: true + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox coverage + + - name: Test without coverage + if: "! matrix.use_coverage" + shell: bash + run: tox -c tox-uv.ini run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz` + + - name: Test with coverage + if: "matrix.use_coverage" + shell: bash + run: tox -c tox-uv.ini run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz` + + - name: Generate coverage report + if: "matrix.use_coverage" + run: python -m coverage xml + + - name: Upload coverage to Codecov + if: "matrix.use_coverage" + uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 + with: + fail_ci_if_error: false + files: ./coverage.xml + verbose: true + + check: # This job does nothing and is only used for the branch protection + if: always() + + needs: + - build + + runs-on: ubuntu-latest + + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 + with: + jobs: ${{ toJSON(needs) }} From 55e87638f293a7a4f0b2635fa0efc76bd8b4f75a Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Sat, 18 Oct 2025 21:48:07 +0200 Subject: [PATCH 3/6] chore: don't add coverage for uv dedicated tests Coverage is already done in the standard tests. --- .github/workflows/test-uv.yml | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/test-uv.yml b/.github/workflows/test-uv.yml index 0cf700ca2c4..c3a61b1db76 100644 --- a/.github/workflows/test-uv.yml +++ b/.github/workflows/test-uv.yml @@ -73,7 +73,6 @@ jobs: python: "3.10" os: ubuntu-latest tox_env: "py310" - use_coverage: true - name: "macos-py310" python: "3.10" @@ -107,28 +106,10 @@ jobs: python -m pip install --upgrade pip pip install tox coverage - - name: Test without coverage - if: "! matrix.use_coverage" + - name: Test shell: bash run: tox -c tox-uv.ini run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz` - - name: Test with coverage - if: "matrix.use_coverage" - shell: bash - run: tox -c tox-uv.ini run -e ${{ matrix.tox_env }}-coverage --installpkg `find dist/*.tar.gz` - - - name: Generate coverage report - if: "matrix.use_coverage" - run: python -m coverage xml - - - name: Upload coverage to Codecov - if: "matrix.use_coverage" - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 - with: - fail_ci_if_error: false - files: ./coverage.xml - verbose: true - check: # This job does nothing and is only used for the branch protection if: always() From 364d604fb38751f5818913cba0506c869fadc4be Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 22 Oct 2025 22:26:19 +0200 Subject: [PATCH 4/6] chore: move uv powered tests into test workflow --- .github/workflows/test-uv.yml | 125 ---------------------------------- .github/workflows/test.yml | 70 +++++++++++++++++++ 2 files changed, 70 insertions(+), 125 deletions(-) delete mode 100644 .github/workflows/test-uv.yml diff --git a/.github/workflows/test-uv.yml b/.github/workflows/test-uv.yml deleted file mode 100644 index c3a61b1db76..00000000000 --- a/.github/workflows/test-uv.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: test uv - -on: - push: - branches: - - main - - "[0-9]+.[0-9]+.x" - - "test-me-*" - tags: - - "[0-9]+.[0-9]+.[0-9]+" - - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" - - pull_request: - branches: - - main - - "[0-9]+.[0-9]+.x" - types: - - opened # default - - synchronize # default - - reopened # default - - ready_for_review # used in PRs created from the release workflow - - workflow_dispatch: # allows manual triggering of the workflow - -env: - PYTEST_ADDOPTS: "--color=yes" - -# Cancel running jobs for the same workflow and branch. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -# Set permissions at the job level. -permissions: {} - -jobs: - package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - persist-credentials: false - - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@efb823f52190ad02594531168b7a2d5790e66516 - - build: - needs: [package] - - runs-on: ${{ matrix.os }} - timeout-minutes: 45 - permissions: - contents: read - - strategy: - fail-fast: false - matrix: - name: [ - "windows-py310", - - "ubuntu-py310", - - "macos-py310", - ] - - include: - - name: "windows-py310" - python: "3.10" - os: windows-latest - tox_env: "py310" - - - name: "ubuntu-py310" - python: "3.10" - os: ubuntu-latest - tox_env: "py310" - - - name: "macos-py310" - python: "3.10" - os: macos-latest - tox_env: "py310" - xfail: true - - continue-on-error: ${{ matrix.xfail && true || false }} - - steps: - - uses: actions/checkout@v5 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Download Package - uses: actions/download-artifact@v5 - with: - name: Packages - path: dist - - - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v6 - with: - python-version: ${{ matrix.python }} - check-latest: true - allow-prereleases: true - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install tox coverage - - - name: Test - shell: bash - run: tox -c tox-uv.ini run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz` - - check: # This job does nothing and is only used for the branch protection - if: always() - - needs: - - build - - runs-on: ubuntu-latest - - steps: - - name: Decide whether the needed jobs succeeded or failed - uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 - with: - jobs: ${{ toJSON(needs) }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b27572aae0..1c5eb584f88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -295,6 +295,76 @@ jobs: files: ./coverage.xml verbose: true + build-uv: + needs: [package] + + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + permissions: + contents: read + + strategy: + fail-fast: false + matrix: + name: [ + "windows-py310", + + "ubuntu-py310", + + "macos-py310", + ] + + include: + - name: "windows-py310" + python: "3.10" + os: windows-latest + tox_env: "py310" + + - name: "ubuntu-py310" + python: "3.10" + os: ubuntu-latest + tox_env: "py310" + + - name: "macos-py310" + python: "3.10" + os: macos-latest + tox_env: "py310" + xfail: true + + continue-on-error: ${{ matrix.xfail && true || false }} + + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Download Package + uses: actions/download-artifact@v5 + with: + name: Packages + path: dist + + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python }} + check-latest: true + allow-prereleases: true + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox>=4 tox-uv>=1 coverage + + - name: Test + shell: bash + env: + UV_RESOLUTION: lowest-direct + UV_PYTHON_PREFERENCE: only-managed + run: tox run -e ${{ matrix.tox_env }} --installpkg `find dist/*.tar.gz` + + check: # This job does nothing and is only used for the branch protection if: always() From 4a2feb88530ee1b5c3343b0176abf4c07142de69 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 22 Oct 2025 22:26:59 +0200 Subject: [PATCH 5/6] chore: add explanation for assert check change in acceptance_test --- testing/acceptance_test.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index f5358168b32..8ec0cddbf72 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1643,13 +1643,9 @@ def test_fail_call(): assert result.ret == ExitCode.TESTS_FAILED result.assert_outcomes(failed=1, passed=1, errors=2) - result.stdout.fnmatch_lines( - [ - "=* short test summary info =*", - "=* 1 failed, 1 passed, 2 errors in * =*", - ] - ) - + # uv managed python versions do not raise the same exception with regard to + # StopIteration. + # See PEP-0479 runtime_errors = { "FAILED test_it.py::test_fail_call - RuntimeError: generator raised StopIteration", "ERROR test_it.py::test_fail_setup - RuntimeError: generator raised StopIteration", From 94c93c1342c89450a8e7d55830cc6f3b450543af Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Wed, 22 Oct 2025 22:27:10 +0200 Subject: [PATCH 6/6] chore: add changelog entry --- changelog/13177.packaging.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/13177.packaging.rst diff --git a/changelog/13177.packaging.rst b/changelog/13177.packaging.rst new file mode 100644 index 00000000000..ef4d0c8ab0b --- /dev/null +++ b/changelog/13177.packaging.rst @@ -0,0 +1,3 @@ +Raised minimal versions of ``exceptiongroup``, ``iniconfig`` and ``pygments`` following uv powered test runs using the ``lowest-direct`` resolution strategy. + +-- by :user:`sgaist`