diff --git a/CHANGES.txt b/CHANGES.txt index 519ced96c7..f604a6955b 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -149,6 +149,8 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Restore the ability of the content-timestamp decider to see that a a source which is a symlink has changed if the file-system target of that link has been modified (issue #3880) + - Modernize a few tests that use now-deprecated unittest.getTestCaseNames + and unittest.makeSuite - Python itself suggests the replacements. From Zhichang Yu: - Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT. diff --git a/SCons/Scanner/ScannerTests.py b/SCons/Scanner/ScannerTests.py index 68332a04e9..b9cb209f6a 100644 --- a/SCons/Scanner/ScannerTests.py +++ b/SCons/Scanner/ScannerTests.py @@ -621,7 +621,9 @@ def suite(): ClassicCPPTestCase, ] for tclass in tclasses: - names = unittest.getTestCaseNames(tclass, 'test_') + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + names = loader.getTestCaseNames(tclass) suite.addTests(list(map(tclass, names))) return suite diff --git a/SCons/Tool/ToolTests.py b/SCons/Tool/ToolTests.py index 7cff7c8944..9338c2d288 100644 --- a/SCons/Tool/ToolTests.py +++ b/SCons/Tool/ToolTests.py @@ -116,7 +116,9 @@ def test_pathfind(self): if __name__ == "__main__": - suite = unittest.makeSuite(ToolTestCase, 'test_') + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + suite = loader.loadTestsFromTestCase(ToolTestCase) TestUnit.run(suite) # Local Variables: diff --git a/SCons/Tool/msvsTests.py b/SCons/Tool/msvsTests.py index 4cbaf0e755..c4d2e9835f 100644 --- a/SCons/Tool/msvsTests.py +++ b/SCons/Tool/msvsTests.py @@ -982,7 +982,9 @@ class msvsEmptyTestCase(msvsTestCase): if k in os.environ: del os.environ[k] - suite = unittest.makeSuite(test_class, 'test_') + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + suite = loader.loadTestsFromTestCase(test_class) if not TestUnit.cli.get_runner()().run(suite).wasSuccessful(): exit_val = 1 finally: diff --git a/SCons/cppTests.py b/SCons/cppTests.py index a9aef9d516..f20c302c16 100644 --- a/SCons/cppTests.py +++ b/SCons/cppTests.py @@ -876,7 +876,9 @@ def scons_current_file(self, t): fileTestCase, ] for tclass in tclasses: - names = unittest.getTestCaseNames(tclass, 'test_') + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + names = loader.getTestCaseNames(tclass) try: names = sorted(set(names)) except NameError: diff --git a/testing/framework/TestCmdTests.py b/testing/framework/TestCmdTests.py index 212c59ab41..3b29091f72 100644 --- a/testing/framework/TestCmdTests.py +++ b/testing/framework/TestCmdTests.py @@ -3389,8 +3389,10 @@ def test_variables(self): ]) suite = unittest.TestSuite() for tclass in tclasses: - names = unittest.getTestCaseNames(tclass, 'test_') - suite.addTests([ tclass(n) for n in names ]) + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + names = loader.getTestCaseNames(tclass) + suite.addTests([tclass(n) for n in names]) if not unittest.TextTestRunner().run(suite).wasSuccessful(): sys.exit(1) diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index 03a5508e21..dff7a50f12 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -2429,8 +2429,10 @@ def test_variables(self): ] suite = unittest.TestSuite() for tclass in tclasses: - names = unittest.getTestCaseNames(tclass, 'test_') - suite.addTests([ tclass(n) for n in names ]) + loader = unittest.TestLoader() + loader.testMethodPrefix = 'test_' + names = loader.getTestCaseNames(tclass) + suite.addTests([tclass(n) for n in names]) if not unittest.TextTestRunner().run(suite).wasSuccessful(): sys.exit(1)