Skip to content

Commit de1f33c

Browse files
authored
Merge pull request #28 from OpenNTI/zodb-optional-py314
Add Python 3.14; Make ZODB optional
2 parents e56747b + 589ffc3 commit de1f33c

File tree

7 files changed

+67
-21
lines changed

7 files changed

+67
-21
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
test:
1313
strategy:
1414
matrix:
15-
python-version: ["pypy-3.10", "3.10", "3.11", "3.12", "3.13"]
15+
python-version: ["pypy-3.11", "3.10", "3.11", "3.12", "3.13", "3.14"]
1616
extras:
17-
- "[test,docs]"
17+
- "[test,docs,zodb,test-zodb]"
1818

1919
runs-on: ubuntu-latest
2020
steps:
@@ -37,10 +37,14 @@ jobs:
3737
coverage combine || true
3838
coverage report -i || true
3939
- name: Lint
40-
if: matrix.python-version == '3.12'
40+
if: matrix.python-version == '3.14'
4141
run: |
4242
python -m pip install -U pylint
4343
pylint src
44+
- name: Test No ZODB
45+
run: |
46+
python -m pip uninstall -y ZODB zope.site persistent
47+
python -m zope.testrunner --test-path=src --auto-color --auto-progress
4448
- name: Submit to Coveralls
4549
# This is a container action, which only runs on Linux.
4650
uses: AndreMiras/coveralls-python-action@develop

CHANGES.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Changes
33
=========
44

5-
4.3.1 (unreleased)
5+
4.4.0 (unreleased)
66
==================
77

8-
- Nothing changed yet.
8+
- Move ZODB and related dependencies to the optional 'zodb' extra.
9+
- Add support for Python 3.14.
910

1011

1112
4.3.0 (2025-04-22)

setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
TESTS_REQUIRE = [
1515
'Acquisition',
16-
'zope.site',
1716
'zope.testrunner',
1817
'testgres >= 1.11',
1918
'psycopg2-binary; python_implementation != "PyPy"',
@@ -47,6 +46,7 @@ def _read(fname):
4746
'Programming Language :: Python :: 3.11',
4847
'Programming Language :: Python :: 3.12',
4948
'Programming Language :: Python :: 3.13',
49+
'Programming Language :: Python :: 3.14',
5050
'Programming Language :: Python :: Implementation :: CPython',
5151
'Programming Language :: Python :: Implementation :: PyPy',
5252
'Topic :: Software Development :: Testing',
@@ -56,7 +56,6 @@ def _read(fname):
5656
packages=find_namespace_packages(where='src'),
5757
package_dir={'': 'src'},
5858
install_requires=[
59-
'ZODB >= 5.6.0',
6059
# Error messages changed in 5.1, reprs changed <= 5.4
6160
'zope.interface >= 5.4.0',
6261
'pyhamcrest',
@@ -72,7 +71,13 @@ def _read(fname):
7271
entry_points=entry_points,
7372
include_package_data=True,
7473
extras_require={
74+
'zodb': [
75+
'ZODB >= 5.6.0',
76+
],
7577
'test': TESTS_REQUIRE,
78+
'test-zodb': [
79+
'zope.site',
80+
],
7681
'docs': [
7782
'Sphinx',
7883
'furo',

src/nti/testing/tests/test_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ def test_thing(self):
8989

9090

9191
def test_configuring_base(self):
92-
import zope.traversing.tests.test_traverser
92+
try:
93+
import zope.traversing.tests.test_traverser
94+
except ModuleNotFoundError:
95+
self.skipTest('zope.traversing not installed')
9396
class MyTest(base.ConfiguringTestBase):
9497
set_up_packages = ('zope.component',
9598
('configure.zcml', 'zope.component'),
@@ -104,7 +107,10 @@ def test_thing(self):
104107
mt.tearDown() # pylint:disable=no-value-for-parameter
105108

106109
def test_shared_configuring_base(self):
107-
import zope.traversing.tests.test_traverser
110+
try:
111+
import zope.traversing.tests.test_traverser
112+
except ModuleNotFoundError:
113+
self.skipTest('zope.traversing not installed')
108114
class MyTest(base.SharedConfiguringTestBase):
109115
layer = None # replaced by metaclass
110116
set_up_packages = ('zope.component',

src/nti/testing/tests/test_main.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,22 @@ def test_suite():
3232
here = os.path.dirname(__file__)
3333

3434
suite = unittest.defaultTestLoader.loadTestsFromName(__name__)
35-
suite.addTest(doctest.DocFileSuite(
36-
'test_component_cleanup_broken.txt'))
35+
try:
36+
import zope.site as has_zope_site
37+
except ModuleNotFoundError:
38+
has_zope_site = None
39+
else:
40+
suite.addTest(doctest.DocFileSuite(
41+
'test_component_cleanup_broken.txt'))
3742

3843
readmedir = here
3944
while not os.path.exists(os.path.join(readmedir, 'setup.py')):
4045
readmedir = os.path.dirname(readmedir)
4146
readme = os.path.join(readmedir, 'README.rst')
42-
suite.addTest(doctest.DocFileSuite(
43-
readme,
44-
module_relative=False,
45-
optionflags=doctest.ELLIPSIS,
46-
))
47+
if has_zope_site:
48+
suite.addTest(doctest.DocFileSuite(
49+
readme,
50+
module_relative=False,
51+
optionflags=doctest.ELLIPSIS,
52+
))
4753
return suite

src/nti/testing/tests/test_zodb.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
import transaction
1515
from transaction.interfaces import NoTransaction
1616
from zope import interface
17-
from nti.testing import zodb
17+
try:
18+
from nti.testing import zodb
19+
base_mock_db_trans = zodb.mock_db_trans
20+
except ModuleNotFoundError as ex:
21+
assert ex.name == 'ZODB'
22+
zodb = None
23+
base_mock_db_trans = object
1824

1925
# pylint:disable=protected-access,pointless-string-statement
2026

@@ -41,7 +47,7 @@ def cacheMinimize(self):
4147
self.minimized = True
4248

4349

44-
class MockDBTrans(zodb.mock_db_trans):
50+
class MockDBTrans(base_mock_db_trans):
4551

4652
def __init__(self, db=None):
4753
if db is None:
@@ -52,6 +58,8 @@ def __init__(self, db=None):
5258
class TestMockDBTrans(unittest.TestCase):
5359

5460
def setUp(self):
61+
if zodb is None:
62+
self.skipTest("ZODB not installed")
5563
self._was_explicit = transaction.manager.explicit
5664
transaction.manager.explicit = False
5765

@@ -226,7 +234,7 @@ def __bool__(self):
226234
class MyMock(MockDBTrans):
227235
seen_tx = None
228236
aborted = False
229-
def on_connection_opened(self, conn):
237+
def on_connection_opened(self, _conn):
230238
# pylint:disable=no-member
231239
self.seen_tx = self._mock_db_trans__current_transaction
232240
abort = self.seen_tx.abort
@@ -255,7 +263,13 @@ def _abort():
255263

256264
class TestZODBLayer(unittest.TestCase):
257265

258-
layer = zodb.ZODBLayer
266+
if zodb is not None:
267+
layer = zodb.ZODBLayer
268+
269+
def setUp(self):
270+
super().setUp()
271+
if zodb is None:
272+
self.skipTest("ZODB not installed")
259273

260274
def test_registration(self):
261275
from ZODB.interfaces import IDatabase
@@ -288,10 +302,14 @@ def __init__(self, *args):
288302
pass
289303

290304
class TestResetDbCaches(unittest.TestCase):
291-
layer = zodb.ZODBLayer
305+
306+
if zodb is not None:
307+
layer = zodb.ZODBLayer
292308

293309
def setUp(self):
294310
super().setUp()
311+
if zodb is None:
312+
self.skipTest("ZODB not installed")
295313
gc.disable()
296314

297315
def tearDown(self):

tox.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ envlist = py38,py39,py310,py311,py312,pypy3,coverage,docs
44
[testenv]
55
extras =
66
test
7+
zodb
8+
test-zodb
79
commands =
810
zope-testrunner --test-path=src --auto-color --auto-progress [] # substitute with tox positional args
911
setenv =
@@ -20,6 +22,10 @@ commands =
2022
deps =
2123
coverage
2224

25+
[testenv:py314]
26+
extras =
27+
test
28+
2329
[testenv:docs]
2430
commands =
2531
sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html

0 commit comments

Comments
 (0)