Skip to content

Python 3.13 failure with unittest.makeSuite #100

@bdice

Description

@bdice

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

conda-forge/pycosat-feedstock#34 is failing because of a function unittest.makeSuite that was deprecated in Python 3.11 and removed in Python 3.13.

suite.addTest(unittest.makeSuite(cls))

This can be replaced with unittest.defaultTestLoader.loadTestsFromTestCase.

This is a patch that I verified is working:

diff --git a/test_pycosat.py b/test_pycosat.py
index f1165d8..0a6969c 100644
--- a/test_pycosat.py
+++ b/test_pycosat.py
@@ -258,7 +258,7 @@ def run(verbosity=1, repeat=1):
     suite = unittest.TestSuite()
     for cls in tests:
         for _ in range(repeat):
-            suite.addTest(unittest.makeSuite(cls))
+            suite.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(cls))
 
     runner = unittest.TextTestRunner(verbosity=verbosity)
     return runner.run(suite)

unittest.defaultTestLoader.loadTestsFromTestCase appears to be backwards compatible as far back as Python 2.7, so there's no loss in compatibility from changing.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type::bugdescribes erroneous operation, use severity::* to classify the type

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions