Skip to content

Commit

Permalink
Merge pull request #94 from lazka/fix-test-deprecations
Browse files Browse the repository at this point in the history
tests: use loadTestsFromTestCase() instead of the deprecated makeSuite()
  • Loading branch information
jaraco authored Dec 29, 2021
2 parents 3054764 + 9c4d48c commit fd06c22
Show file tree
Hide file tree
Showing 41 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion distutils/tests/test_archive_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def test_tarfile_root_owner(self):
archive.close()

def test_suite():
return unittest.makeSuite(ArchiveUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ArchiveUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_bdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_skip_build(self):


def test_suite():
return unittest.makeSuite(BuildTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_bdist_dumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_simple_built(self):
self.assertEqual(contents, sorted(wanted))

def test_suite():
return unittest.makeSuite(BuildDumbTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildDumbTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_bdist_msi.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_minimal(self):


def test_suite():
return unittest.makeSuite(BDistMSITestCase)
return unittest.TestLoader().loadTestsFromTestCase(BDistMSITestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_bdist_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def test_no_optimize_flag(self):
os.remove(os.path.join(pkg_dir, 'dist', 'foo-0.1-1.noarch.rpm'))

def test_suite():
return unittest.makeSuite(BuildRpmTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildRpmTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_bdist_wininst.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_get_exe_bytes(self):
self.assertGreater(len(exe_file), 10)

def test_suite():
return unittest.makeSuite(BuildWinInstTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildWinInstTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_finalize_options(self):
self.assertEqual(cmd.executable, os.path.normpath(sys.executable))

def test_suite():
return unittest.makeSuite(BuildTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_build_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_run(self):
self.assertIn('libfoo.a', os.listdir(build_temp))

def test_suite():
return unittest.makeSuite(BuildCLibTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildCLibTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions distutils/tests/test_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ def build_ext(self, *args, **kwargs):

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

if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_dont_write_bytecode(self):


def test_suite():
return unittest.makeSuite(BuildPyTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildPyTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_build_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_version_int(self):
self.assertIn(name, built)

def test_suite():
return unittest.makeSuite(BuildScriptsTestCase)
return unittest.TestLoader().loadTestsFromTestCase(BuildScriptsTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_check_all(self):
'restructuredtext': 1})

def test_suite():
return unittest.makeSuite(CheckTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CheckTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_simple_run(self):
cmd.run()

def test_suite():
return unittest.makeSuite(cleanTestCase)
return unittest.TestLoader().loadTestsFromTestCase(cleanTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_debug_print(self):
debug.DEBUG = False

def test_suite():
return unittest.makeSuite(CommandTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CommandTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_config_interpolation(self):


def test_suite():
return unittest.makeSuite(PyPIRCCommandTestCase)
return unittest.TestLoader().loadTestsFromTestCase(PyPIRCCommandTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_config_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_clean(self):
self.assertFalse(os.path.exists(f))

def test_suite():
return unittest.makeSuite(ConfigTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ConfigTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_debug_mode(self):
self.assertEqual(stdout.readlines()[0], wanted)

def test_suite():
return unittest.makeSuite(CoreTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CoreTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_get_msvcr(self):
self.assertRaises(ValueError, get_msvcr)

def test_suite():
return unittest.makeSuite(CygwinCCompilerTestCase)
return unittest.TestLoader().loadTestsFromTestCase(CygwinCCompilerTestCase)

if __name__ == '__main__':
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_dep_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_newer_group(self):


def test_suite():
return unittest.makeSuite(DepUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(DepUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_dir_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_copy_tree_exception_in_listdir(self):


def test_suite():
return unittest.makeSuite(DirUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(DirUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions distutils/tests/test_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ def test_read_metadata(self):

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

if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_extension_init(self):
"Unknown Extension options: 'chic'")

def test_suite():
return unittest.makeSuite(ExtensionTestCase)
return unittest.TestLoader().loadTestsFromTestCase(ExtensionTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_copy_file_hard_link_failure(self):


def test_suite():
return unittest.makeSuite(FileUtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(FileUtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
4 changes: 2 additions & 2 deletions distutils/tests/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def test_symlink_loop(self):

def test_suite():
return unittest.TestSuite([
unittest.makeSuite(FileListTestCase),
unittest.makeSuite(FindAllTestCase),
unittest.TestLoader().loadTestsFromTestCase(FileListTestCase),
unittest.TestLoader().loadTestsFromTestCase(FindAllTestCase),
])


Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_debug_mode(self):


def test_suite():
return unittest.makeSuite(InstallTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_install_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_simple_run(self):
self.assertTrue(os.path.exists(os.path.join(inst, rone)))

def test_suite():
return unittest.makeSuite(InstallDataTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallDataTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_install_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_simple_run(self):
self.assertEqual(len(cmd.get_outputs()), 2)

def test_suite():
return unittest.makeSuite(InstallHeadersTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallHeadersTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_install_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_dont_write_bytecode(self):


def test_suite():
return unittest.makeSuite(InstallLibTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallLibTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_install_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def write_script(name, text):


def test_suite():
return unittest.makeSuite(InstallScriptsTestCase)
return unittest.TestLoader().loadTestsFromTestCase(InstallScriptsTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_non_ascii(self):
'Fαtal\t\\xc8rr\\u014dr')

def test_suite():
return unittest.makeSuite(TestLog)
return unittest.TestLoader().loadTestsFromTestCase(TestLog)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_msvc9compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_remove_entire_manifest(self):


def test_suite():
return unittest.makeSuite(msvc9compilerTestCase)
return unittest.TestLoader().loadTestsFromTestCase(msvc9compilerTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def CCompiler_spawn(self, cmd):


def test_suite():
return unittest.makeSuite(msvccompilerTestCase)
return unittest.TestLoader().loadTestsFromTestCase(msvccompilerTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def test_show_response(self):


def test_suite():
return unittest.makeSuite(RegisterTestCase)
return unittest.TestLoader().loadTestsFromTestCase(RegisterTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def test_make_distribution_owner_group(self):
archive.close()

def test_suite():
return unittest.makeSuite(SDistTestCase)
return unittest.TestLoader().loadTestsFromTestCase(SDistTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_spawn_missing_exe(self):


def test_suite():
return unittest.makeSuite(SpawnTestCase)
return unittest.TestLoader().loadTestsFromTestCase(SpawnTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def test_parse_config_h(self):

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


Expand Down
2 changes: 1 addition & 1 deletion distutils/tests/test_text_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_input(count, description, file, expected_result):
in_file.close()

def test_suite():
return unittest.makeSuite(TextFileTestCase)
return unittest.TestLoader().loadTestsFromTestCase(TextFileTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_has_function(self):


def test_suite():
return unittest.makeSuite(UnixCCompilerTestCase)
return unittest.TestLoader().loadTestsFromTestCase(UnixCCompilerTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test_wrong_exception_order(self):


def test_suite():
return unittest.makeSuite(uploadTestCase)
return unittest.TestLoader().loadTestsFromTestCase(uploadTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_grok_environment_error(self):


def test_suite():
return unittest.makeSuite(UtilTestCase)
return unittest.TestLoader().loadTestsFromTestCase(UtilTestCase)

if __name__ == "__main__":
run_unittest(test_suite())
2 changes: 1 addition & 1 deletion distutils/tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_cmp(self):
(v1, v2, res))

def test_suite():
return unittest.makeSuite(VersionTestCase)
return unittest.TestLoader().loadTestsFromTestCase(VersionTestCase)

if __name__ == "__main__":
run_unittest(test_suite())

0 comments on commit fd06c22

Please sign in to comment.