Skip to content

Commit 79bc6e0

Browse files
authored
Support Python 3.15 (#61)
* Configuring for pure-python * Deprecate zope.testing.doctestcase in favour of plain doctest. Points users to doctest.DocTestSuite/DocFileSuite as the migration path.
1 parent e5efd03 commit 79bc6e0

10 files changed

Lines changed: 94 additions & 18 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: linting
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v6
24+
- uses: actions/checkout@v7
2525
- uses: actions/setup-python@v6
2626
with:
2727
python-version: '3.13'

.github/workflows/tests.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- ["3.12", "py312"]
3131
- ["3.13", "py313"]
3232
- ["3.14", "py314"]
33+
- ["3.15", "py315"]
3334
- ["pypy-3.11", "pypy3"]
3435
- ["3.11", "docs"]
3536
- ["3.11", "coverage"]
@@ -42,12 +43,12 @@ jobs:
4243
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
4344
name: ${{ matrix.os[0] }}-${{ matrix.config[1] }}
4445
steps:
45-
- uses: actions/checkout@v6
46+
- uses: actions/checkout@v7
4647
with:
4748
persist-credentials: false
4849
- name: Install uv + caching
49-
# astral/setup-uv@7.2.0
50-
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b
50+
# astral/setup-uv@8.2.0
51+
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39
5152
with:
5253
enable-cache: true
5354
cache-dependency-glob: |
@@ -63,3 +64,32 @@ jobs:
6364
uvx coveralls --service=github
6465
env:
6566
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Build package artifacts
69+
if: >
70+
matrix.os[0] == 'ubuntu'
71+
&& matrix.config[1] == 'py314'
72+
run: |
73+
rm -f dist/*
74+
pip install -U packaging "setuptools >= 78.1.1,< 82" wheel twine
75+
python setup.py sdist
76+
python setup.py bdist_wheel
77+
78+
- name: Upload package wheel
79+
if: >
80+
matrix.os[0] == 'ubuntu'
81+
&& matrix.config[1] == 'py314'
82+
uses: actions/upload-artifact@v7
83+
with:
84+
name: zope.testing.whl
85+
path: dist/*whl
86+
87+
- name: Upload package source distribution
88+
if: >
89+
matrix.os[0] == 'ubuntu'
90+
&& matrix.config[1] == 'py314'
91+
uses: actions/upload-artifact@v7
92+
with:
93+
name: zope.testing.tar.gz
94+
path: dist/*gz
95+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ lib64
2828
log/
2929
parts/
3030
pyvenv.cfg
31+
share/
3132
testing.log
3233
var/

.meta.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# https://github.com/zopefoundation/meta/tree/master/src/zope/meta/pure-python
33
[meta]
44
template = "pure-python"
5-
commit-id = "f6df9072"
5+
commit-id = "6a771177"
66

77
[python]
88
with-pypy = true
99
with-docs = true
1010
with-sphinx-doctests = true
1111
with-windows = true
12-
with-future-python = false
12+
with-future-python = true
1313
with-macos = false
14+
with-free-threaded-python = false
1415

1516
[coverage]
1617
fail-under = 97

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
minimum_pre_commit_version: '3.6'
44
repos:
55
- repo: https://github.com/pycqa/isort
6-
rev: "7.0.0"
6+
rev: "8.0.1"
77
hooks:
88
- id: isort
99
- repo: https://github.com/hhatto/autopep8
@@ -20,6 +20,7 @@ repos:
2020
rev: 0.4.3
2121
hooks:
2222
- id: teyit
23+
language_version: python3.13
2324
- repo: https://github.com/PyCQA/flake8
2425
rev: "7.3.0"
2526
hooks:

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
6.2 (unreleased)
66
================
77

8+
- Add support for Python 3.15.
9+
10+
- Deprecate ``zope.testing.doctestcase`` in favour of plain ``doctest``
11+
(e.g. ``doctest.DocTestSuite`` or ``doctest.DocFileSuite``).
12+
813
- Move package metadata from setup.py to pyproject.toml.
914

1015

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
[build-system]
55
requires = [
6-
"setuptools >= 78.1.1,< 81",
6+
"setuptools >= 78.1.1,< 82",
77
"wheel",
88
]
99
build-backend = "setuptools.build_meta"
1010

11-
1211
[project]
1312
name = "zope.testing"
1413
version = "6.2.dev0"

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Generated with zope.meta (https://zopemeta.readthedocs.io/) from:
22
# https://github.com/zopefoundation/meta/tree/master/src/zope/meta/pure-python
3-
43
[flake8]
54
doctests = 1
65

src/zope/testing/doctestcase.py

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
"""
44
import doctest
55
import inspect
6+
import io
67
import os
78
import re
89
import sys
910
import types
11+
import unittest
12+
import warnings
13+
14+
15+
warnings.warn(
16+
'zope.testing.doctestcase is deprecated and will be removed in a '
17+
'future release. Use plain doctest (e.g. doctest.DocTestSuite or '
18+
'doctest.DocFileSuite) instead.',
19+
DeprecationWarning,
20+
stacklevel=2)
1021

1122

1223
__all__ = [
@@ -203,11 +214,38 @@ def name_from_path(path):
203214

204215
def _run_test(self, test, globs, name, path,
205216
optionflags, checker, testname='self', lineno=0):
217+
# This deliberately avoids DocTestCase.run()/.runTest(), which (as of
218+
# Python 3.15) report each example as a separate subtest of the
219+
# enclosing unittest result, rather than raising on failure. We want
220+
# the whole doctest to be run in one go, with any failures raised
221+
# here so that they become a failure of *this* test.
206222
globs.update(getattr(self, 'globs', ()))
207223
globs[testname] = self
208224
optionflags |= doctest.IGNORE_EXCEPTION_DETAIL
209-
doctest.DocTestCase(
210-
_parser.get_doctest(test, globs, name, path, lineno),
211-
optionflags=optionflags,
212-
checker=checker,
213-
).runTest()
225+
if not (optionflags & doctest.REPORTING_FLAGS):
226+
optionflags |= getattr(doctest, '_unittest_reportflags', 0)
227+
228+
dtest = _parser.get_doctest(test, globs, name, path, lineno)
229+
runner = doctest.DocTestRunner(
230+
optionflags=optionflags, checker=checker, verbose=False)
231+
out = io.StringIO()
232+
old_stdout = sys.stdout
233+
try:
234+
runner.DIVIDER = "-" * 70
235+
results = runner.run(dtest, out=out.write, clear_globs=False)
236+
# TestResults.skipped was only added in Python 3.13.
237+
if hasattr(results, 'skipped') and (
238+
results.skipped == results.attempted):
239+
raise unittest.SkipTest("all examples were skipped")
240+
finally:
241+
sys.stdout = old_stdout
242+
243+
if results.failed:
244+
lineno = ('unknown line number' if dtest.lineno is None
245+
else str(dtest.lineno))
246+
lname = dtest.name.rsplit('.', 1)[-1]
247+
raise self.failureException(
248+
'Failed doctest test for %s\n'
249+
' File "%s", line %s, in %s\n\n%s'
250+
% (dtest.name, dtest.filename, lineno, lname,
251+
out.getvalue().rstrip('\n')))

tox.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ envlist =
1010
py312
1111
py313
1212
py314
13+
py315
1314
pypy3
1415
docs
1516
coverage
@@ -18,8 +19,9 @@ envlist =
1819
usedevelop = true
1920
package = wheel
2021
wheel_build_env = .pkg
22+
pip_pre = py315: true
2123
deps =
22-
setuptools >= 78.1.1,< 81
24+
setuptools >= 78.1.1,< 82
2325
commands =
2426
zope-testrunner --test-path=src {posargs:-vc}
2527
sphinx-build -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
@@ -37,12 +39,12 @@ description = ensure that the distribution is ready to release
3739
basepython = python3
3840
skip_install = true
3941
deps =
40-
setuptools >= 78.1.1,< 81
42+
setuptools >= 78.1.1,< 82
4143
wheel
4244
twine
4345
build
4446
check-manifest
45-
check-python-versions >= 0.20.0
47+
check-python-versions >= 0.24.2
4648
wheel
4749
commands_pre =
4850
commands =

0 commit comments

Comments
 (0)