Skip to content

Commit

Permalink
ensure test compatibility with both ZODB<6 and ZODB>=6 by looking…
Browse files Browse the repository at this point in the history
… for ZODB inherited tests with prefixes `check` and `test`
  • Loading branch information
d-maurer committed Jul 28, 2023
1 parent 99e72a7 commit f686914
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Changelog
- fix problems with Python 3.12.0b4
(`issue 231 <https://github.com/zopefoundation/ZEO/issues/231>_`).

- ensure test compatibility with both ``ZODB<6`` and ``ZODB>=6``
by looking for ZODB inherited tests with prefixes
``check`` (used by ``ZODB<6``)
and ``test`` (used by ``ZODB>=6``)
(`issue 233 <https://github.com/zopefoundation/ZEO/issues/233>_`).


5.4.0 (2023-01-18)
------------------
Expand Down
37 changes: 27 additions & 10 deletions src/ZEO/tests/testZEO.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ class FullGenericTests(
IterationTests.IterationTests):
"""Extend GenericTests with tests that MappingStorage can't pass."""

def testPackUndoLog(self):
# Prevent execution of the test inherited from ``ZODB>=6.0``.
#
# An adapted version of this test is executed via the following
# ``checkPackUndoLog``.
#
# Once support for ``ZODB<6.0`` is dropped, this function
# can go away and ``checkPackUndoLog`` can get renamed
# to ``testPackUndoLog``.
pass

def checkPackUndoLog(self):
# PackableStorage.PackableUndoStorage wants to adjust
# time.sleep and time.time to cooperate and pretend for time
Expand Down Expand Up @@ -1868,10 +1879,19 @@ def test_suite():
"ClientDisconnected"),
)),
))
test_loader = unittest.TestLoader()
test_loader.testMethodPrefix = 'check'
zeo.addTest(test_loader.loadTestsFromTestCase(
ClientConflictResolutionTests))

def add_tests(to, case):
"""add tests from *case* to *to*.
This adds tests with prefixes ``check`` and ``test``
to be compatible with ``ZODB<6`` and ``ZODB>=6``.
"""
for prefix in ('check', 'test'):
test_loader = unittest.TestLoader()
test_loader.testMethodPrefix = prefix
to.addTest(test_loader.loadTestsFromTestCase(case))

add_tests(zeo, ClientConflictResolutionTests)
zeo.layer = ZODB.tests.util.MininalTestLayer('testZeo-misc')
suite.addTest(zeo)

Expand All @@ -1892,9 +1912,7 @@ def test_suite():
'data.fs', 'blobs', extrafsoptions='pack-gc false')
))
for klass in quick_test_classes:
test_loader = unittest.TestLoader()
test_loader.testMethodPrefix = 'check'
zeo.addTest(test_loader.loadTestsFromTestCase(klass))
add_tests(zeo, klass)
zeo.layer = ZODB.tests.util.MininalTestLayer('testZeo-misc2')
suite.addTest(zeo)

Expand All @@ -1916,9 +1934,8 @@ def test_suite():

# Put the heavyweights in their own layers
for klass in slow_test_classes:
test_loader = unittest.TestLoader()
test_loader.testMethodPrefix = 'check'
sub = test_loader.loadTestsFromTestCase(klass)
sub = unittest.TestSuite()
add_tests(sub, klass)
sub.layer = ZODB.tests.util.MininalTestLayer(klass.__name__)
suite.addTest(sub)

Expand Down

0 comments on commit f686914

Please sign in to comment.