diff -r 4b42d7f288c5 Lib/test/test_genericpath.py --- a/Lib/test/test_genericpath.py Thu Jan 03 09:22:41 2013 +0100 +++ b/Lib/test/test_genericpath.py Thu Jan 03 09:00:55 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 16748: 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', @@ -408,7 +409,7 @@ def test_main(): - support.run_unittest(GenericTest) + support.run_unittest(TestGenericTest) if __name__=="__main__": diff -r 4b42d7f288c5 Lib/test/test_macpath.py --- a/Lib/test/test_macpath.py Thu Jan 03 09:22:41 2013 +0100 +++ b/Lib/test/test_macpath.py Thu Jan 03 09:00:55 2013 -0600 @@ -115,7 +115,7 @@ self.assertEqual(normpath(b"a:b:"), b"a:b") -class MacCommonTest(test_genericpath.CommonTest): +class MacCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = macpath diff -r 4b42d7f288c5 Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Thu Jan 03 09:22:41 2013 +0100 +++ b/Lib/test/test_ntpath.py Thu Jan 03 09:00:55 2013 -0600 @@ -257,7 +257,7 @@ ntpath.sameopenfile(-1, -1) -class NtCommonTest(test_genericpath.CommonTest): +class NtCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = ntpath attributes = ['relpath', 'splitunc'] diff -r 4b42d7f288c5 Lib/test/test_posixpath.py --- a/Lib/test/test_posixpath.py Thu Jan 03 09:22:41 2013 +0100 +++ b/Lib/test/test_posixpath.py Thu Jan 03 09:00:55 2013 -0600 @@ -462,7 +462,7 @@ os.getcwdb = real_getcwdb -class PosixCommonTest(test_genericpath.CommonTest): +class PosixCommonTest(test_genericpath.CommonTest, unittest.TestCase): pathmodule = posixpath attributes = ['relpath', 'samefile', 'sameopenfile', 'samestat']