Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13 failure with unittest.makeSuite #100

Open
2 tasks done
bdice opened this issue Nov 25, 2024 · 0 comments
Open
2 tasks done

Python 3.13 failure with unittest.makeSuite #100

bdice opened this issue Nov 25, 2024 · 0 comments
Labels
type::bug describes erroneous operation, use severity::* to classify the type

Comments

@bdice
Copy link

bdice commented Nov 25, 2024

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

@bdice bdice added the type::bug describes erroneous operation, use severity::* to classify the type label Nov 25, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in 🧭 Planning Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::bug describes erroneous operation, use severity::* to classify the type
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant