Skip to content

Commit

Permalink
Merge pull request #70 from plone/py-3.13-unittest
Browse files Browse the repository at this point in the history
Fix removed `unittest.makeSuite` in python 3.13
  • Loading branch information
mauritsvanrees authored Nov 29, 2024
2 parents bcf7f94 + 0d82221 commit 3616e70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
13 changes: 7 additions & 6 deletions Products/PortalTransforms/tests/test_intelligenttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,11 @@ def testWhitespace(self):


def test_suite():
from unittest import makeSuite
from unittest import TestSuite
import unittest

suite = TestSuite()
suite.addTest(makeSuite(TestIntelligentTextToHtml))
suite.addTest(makeSuite(TestHtmlToIntelligentText))
return suite
return unittest.TestSuite(
(
unittest.defaultTestLoader.loadTestsFromTestCase(TestIntelligentTextToHtml),
unittest.defaultTestLoader.loadTestsFromTestCase(TestHtmlToIntelligentText),
)
)
7 changes: 3 additions & 4 deletions Products/PortalTransforms/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,9 @@ class TransformTestSubclass(TransformTest):


def test_suite():
from unittest import makeSuite
from unittest import TestSuite
import unittest

suite = TestSuite()
suite = unittest.TestSuite()
for test in make_tests():
suite.addTest(makeSuite(test))
suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(test))
return suite
16 changes: 8 additions & 8 deletions docs/dev_manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Writing a new transformation
============================
Writing a new transform should be an easy task. You only have to follow a
simple interface to do it, but knowing some advanced features and provided
utilities may help to do it quicker...
utilities may help to do it quicker...


Related interfaces
Expand Down Expand Up @@ -182,16 +182,16 @@ Transform utilities may be found in the libtransforms subpackage. You'll find
there the following modules :

*commandtransform*
provides a base class for external command based transforms.
provides a base class for external command based transforms.

*retransform*
provides a base class for regular expression based transforms.
provides a base class for regular expression based transforms.

*html4zope*
provides a docutils HTML writer for Zope.

*utils*
provides some utilities functions.
provides some utilities functions.


Write a test your transform!
Expand All @@ -202,11 +202,11 @@ cola into beer (I let you find MIME type for these content types ;). Basically,
your test file should be::

from test_transforms import make_tests

tests =('Products.MyTransforms.colabeer', "drink.cola", "drink.beer", None, 0)

def test_suite():
return TestSuite([makeSuite(test) for test in make_tests()])
return TestSuite([unittest.defaultTestLoader.loadTestsFromTestCase(test) for test in make_tests()])

if __name__=='__main__':
main(defaultTest='test_suite')
Expand All @@ -216,10 +216,10 @@ your test file should be::
In this example:

- "Products.MyTransforms.colabeer" is the module defining your transform (you
can also give directly the transform instance).
can also give directly the transform instance).

- "drink.cola" is the name of the file containing data to give to your transform
as input.
as input.

- "drink.beer" is the file containing expected transform result (what the getData
method of idatastream will return).
Expand Down
2 changes: 2 additions & 0 deletions news/70.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix removed `unittest.makeSuite` in python 3.13
[petschki]

0 comments on commit 3616e70

Please sign in to comment.