Skip to content

Commit

Permalink
Convert from unittest.makeSuite to unittest.TestLoader().loadTestsFro…
Browse files Browse the repository at this point in the history
…mTestCase. The former is a (for some reason) deprecated shortcut for the latter.
  • Loading branch information
jamadden committed Oct 11, 2024
1 parent 058781a commit d922ba3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/relstorage/adapters/tests/test_replica.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_next_with_new_conf(self):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ReplicaSelectorTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ReplicaSelectorTests))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/adapters/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def thing(self, arg1, arg2=False):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestNoOp))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestNoOp))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/cache/tests/test_cache_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class NoTest(unittest.TestCase):
@unittest.skip("ZEO not installed")
def test_cache_trace_analysis(self):
"Does nothing"
suite.addTest(unittest.makeSuite(NoTest))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(NoTest))
else:
suite.addTest(
doctest.DocFileSuite(
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/tests/blob/testblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def add_test_based_on_test_class(klass, **attr):
)
new_class.__module__ = klass.__module__
new_class = unittest.skipUnless(storage_is_available, str(storage_is_available))(new_class)
suite.addTest(unittest.makeSuite(new_class))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(new_class))

add_test_based_on_test_class(TestBlobTransaction)
add_test_based_on_test_class(TestBlobImportExport)
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/tests/test_treemark.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_64bit_circular(self):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestTreeMarker))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestTreeMarker))
return suite

if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions src/relstorage/tests/test_zodbconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@ def deep_compare_current_states(self):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(FSZODBConvertTests))
suite.addTest(unittest.makeSuite(ZlibWrappedFSZODBConvertTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(FSZODBConvertTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ZlibWrappedFSZODBConvertTests))
return suite

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/relstorage/tests/test_zodbpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_pack_defaults(self):

def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ZODBPackScriptTests))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(ZODBPackScriptTests))
return suite

if __name__ == '__main__':
Expand Down
14 changes: 8 additions & 6 deletions src/relstorage/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_suite(self):
from .reltestbase import AbstractIDBOptionsTest

suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(type(
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(type(
self.__name__ + 'DBOptionsTest',
(AbstractIDBOptionsTest,),
{'db_options': self.drivers}
Expand All @@ -245,7 +245,7 @@ def test_suite(self):
)
# Checking the driver is just a unit test, it doesn't connect or
# need a layer
suite.addTest(unittest.makeSuite(
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
self.__skipping_if_not_available(
type(
self.__name__ + 'DBDriverTest_' + available.escaped_driver_name,
Expand Down Expand Up @@ -403,19 +403,21 @@ def _add_driver_to_suite(self, suite, layer_prefix, driver_available):
# pylint:disable=too-many-locals
for klass in self._make_check_classes():
klass = self._new_class_for_driver(klass, driver_available)
suite.addTest(unittest.makeSuite(klass, "check"))
loader = unittest.TestLoader()
loader.testMethodPrefix = 'check'
suite.addTest(loader.loadTestsFromTestCase(klass))

for klass in self._make_test_classes():
klass = self._new_class_for_driver(klass, driver_available)
suite.addTest(unittest.makeSuite(klass))
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(klass))

for klass in self._make_zodbconvert_classes():
suite.addTest(unittest.makeSuite(
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
self._new_class_for_driver(klass,
driver_available)))

for klass in self.extra_test_classes:
suite.addTest(unittest.makeSuite(
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
self._new_class_for_driver(klass,
driver_available)))

Expand Down

0 comments on commit d922ba3

Please sign in to comment.