Skip to content

Commit

Permalink
Merge pull request #100 from plone/unittest-py-3.13
Browse files Browse the repository at this point in the history
Fix README for removed `unittest.makeSuite`
  • Loading branch information
davisagli authored Nov 28, 2024
2 parents 7336acc + d6b3fb6 commit a7898ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions news/100.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix README for removed `unittest.makeSuite` in python 3.13.
[petschki]
8 changes: 4 additions & 4 deletions src/plone/testing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,14 @@ To add the doctests from a particular module to a test suite, you need to use th
>>> def test_suite():
... suite = unittest.TestSuite()
... suite.addTests([
... unittest.makeSuite(TestFasterThanLightTravel), # our previous test
... unittest.defaultTestLoader.loadTestsFromTestCase(TestFasterThanLightTravel), # our previous test
... doctest.DocTestSuite('spaceship.utils'),
... ])
... return suite

Here, we have given the name of the module to check as a string dotted name.
It is also possible to import a module and pass it as an object.
The code above passes a list to ``addTests()``, making it easy to add several sets of tests to the suite: the list can be constructed from calls to ``DocTestSuite()``, ``DocFileSuite()`` (shown below) and ``makeSuite()`` (shown above).
The code above passes a list to ``addTests()``, making it easy to add several sets of tests to the suite: the list can be constructed from calls to ``DocTestSuite()``, ``DocFileSuite()`` (shown below) and ``unittest.defaultTestLoader.loadTestsFromTestCase()`` (shown above).

Remember that if you add a ``test_suite()`` function to a module that also has ``TestCase``-derived python tests, those tests will no longer be automatically picked up by ``zope.testing``, so you need to add them to the test suite explicitly.

Expand Down Expand Up @@ -901,7 +901,7 @@ For example, if we had a file called ``spaceship.txt`` with doctests, we could a
>>> def test_suite():
... suite = unittest.TestSuite()
... suite.addTests([
... unittest.makeSuite(TestFasterThanLightTravel),
... unittest.defaultTestLoader.loadTestsFromTestCase(TestFasterThanLightTravel),
... doctest.DocTestSuite('spaceship.utils'),
... doctest.DocFileSuite('spaceship.txt'),
... ])
Expand All @@ -920,7 +920,7 @@ It is possible to pass several tests to the suite, e.g.::
>>> def test_suite():
... suite = unittest.TestSuite()
... suite.addTests([
... unittest.makeSuite(TestFasterThanLightTravel),
... unittest.defaultTestLoader.loadTestsFromTestCase(TestFasterThanLightTravel),
... doctest.DocTestSuite('spaceship.utils'),
... doctest.DocFileSuite('spaceship.txt', 'warpdrive.txt',),
... ])
Expand Down

0 comments on commit a7898ce

Please sign in to comment.