Skip to content

Commit

Permalink
libtbx: updates for Python 3.13
Browse files Browse the repository at this point in the history
- unittest.makeSuite -> unittest.defaultTestLoader.loadTestsFromTestCase
- __firstlineno__ and __static_attributes__ are new default class attributes
- leading whitespace in docstring is removed
  • Loading branch information
bkpoon committed Oct 2, 2024
1 parent 99886c7 commit ee4f907
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 6 additions & 6 deletions libtbx/clusterTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ def testLostFunctionReference(self):
if (__name__ == "__main__"):
unittest.TextTestRunner(stream=sys.stdout, verbosity=0).run(
unittest.TestSuite((
unittest.makeSuite(HClusterSmallListTestCase),
unittest.makeSuite(HClusterIntegerTestCase),
unittest.makeSuite(HClusterStringTestCase),
unittest.makeSuite(KClusterSmallListTestCase),
unittest.makeSuite(KCluster2DTestCase),
unittest.makeSuite(KClusterSFBugs),
unittest.defaultTestLoader.loadTestsFromTestCase(HClusterSmallListTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(HClusterIntegerTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(HClusterStringTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(KClusterSmallListTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(KCluster2DTestCase),
unittest.defaultTestLoader.loadTestsFromTestCase(KClusterSFBugs),
))
)
3 changes: 3 additions & 0 deletions libtbx/object_oriented_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def __init__(cls, name, bases, namespace, **kwds):
if sys.hexversion >= 0x03000000:
if name in ('__qualname__',):
continue
if sys.version_info.major == 3 and sys.version_info.minor >= 13:
if name in ('__firstlineno__', '__static_attributes__'):
continue
assert not hasattr(target_class, name), (
"class %s already has attribute '%s'"
% (target_class.__name__, name))
Expand Down
7 changes: 5 additions & 2 deletions libtbx/tst_object_oriented_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def f(x):
pass
else:
raise Exception_expected
assert mf.__doc__ == """ Documentation for function f """
# Python 3.13 automatically strips leading spaces
assert mf.__doc__ == """ Documentation for function f """ \
or mf.__doc__ == """Documentation for function f """

def exercise_memoize_with_injector():
class foo(object):
Expand Down Expand Up @@ -97,7 +99,8 @@ def f(self, x):
assert diagnostic == ['+']*4
assert o1.f(1) == 2
assert diagnostic == ['+']*4
assert o1.f.__doc__ == " Documentation for method f "
assert o1.f.__doc__ == " Documentation for method f " \
or o1.f.__doc__ == "Documentation for method f "

class _foo_extension(oop.injector, foo):
def g(self, n):
Expand Down

0 comments on commit ee4f907

Please sign in to comment.