diff -r 4617b7ac302a Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py Tue Jan 08 11:27:18 2013 +0000 +++ b/Lib/test/test_genericpath.py Wed Jan 09 09:19:00 2013 -0600 @@ -17,9 +17,7 @@ pass -class GenericTest(unittest.TestCase): - # The path module to be tested - pathmodule = genericpath +class GenericTest: common_attributes = ['commonprefix', 'getsize', 'getatime', 'getctime', 'getmtime', 'exists', 'isdir', 'isfile'] attributes = [] @@ -270,13 +268,16 @@ self.assertTrue(self.pathmodule.sameopenfile( a.fileno(), b.fileno())) +class TestGenericTest(GenericTest, unittest.TestCase): + # Issue 16852: GenericTest can't inherit from unittest.TestCase + # for test discovery purposes; CommonTest inherits from GenericTest + # and is only meant to be inherited by others. + pathmodule = genericpath # Following TestCase is not supposed to be run from test_genericpath. # It is inherited by other test modules (macpath, ntpath, posixpath). class CommonTest(GenericTest): - # The path module to be tested - pathmodule = None common_attributes = GenericTest.common_attributes + [ # Properties 'curdir', 'pardir', 'extsep', 'sep', @@ -407,9 +408,5 @@ self.test_abspath() -def test_main(): - support.run_unittest(GenericTest) - - if __name__=="__main__": - test_main() + unittest.main() diff -r 4617b7ac302a Lib/test/test_macpath.py --- a/Lib/test/test_macpath.py Tue Jan 08 11:27:18 2013 +0000 +++ b/Lib/test/test_macpath.py Wed Jan 09 09:19:00 2013 -0600 @@ -115,13 +115,9 @@ self.assertEqual(normpath(b"a:b:"), b"a:b") -class MacCommonTest(test_genericpath.CommonTest): +class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = macpath -def test_main(): - support.run_unittest(MacPathTestCase, MacCommonTest) - - if __name__ == "__main__": - test_main() + unittest.main() diff -r 4617b7ac302a Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Tue Jan 08 11:27:18 2013 +0000 +++ b/Lib/test/test_ntpath.py Wed Jan 09 09:19:00 2013 -0600 @@ -257,14 +257,10 @@ ntpath.sameopenfile(-1, -1) -class NtCommonTest(test_genericpath.CommonTest): +class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = ntpath attributes = ['relpath', 'splitunc'] -def test_main(): - support.run_unittest(TestNtpath, NtCommonTest) - - if __name__ == "__main__": unittest.main() diff -r 4617b7ac302a Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py Tue Jan 08 11:27:18 2013 +0000 +++ b/Lib/test/test_posixpath.py Wed Jan 09 09:19:00 2013 -0600 @@ -462,14 +462,10 @@ os.getcwdb = real_getcwdb -class PosixCommonTest(test_genericpath.CommonTest): +class PosixCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = posixpath attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat'] -def test_main(): - support.run_unittest(PosixPathTest, PosixCommonTest) - - if __name__=="__main__": - test_main() + unittest.main()