@@ -17,9 +17,7 @@ def safe_rmdir(dirname):
1717 pass
1818
1919
20- class GenericTest (unittest .TestCase ):
21- # The path module to be tested
22- pathmodule = genericpath
20+ class GenericTest :
2321 common_attributes = ['commonprefix' , 'getsize' , 'getatime' , 'getctime' ,
2422 'getmtime' , 'exists' , 'isdir' , 'isfile' ]
2523 attributes = []
@@ -190,13 +188,16 @@ def test_isfile(self):
190188 support .unlink (support .TESTFN )
191189 safe_rmdir (support .TESTFN )
192190
191+ class TestGenericTest (GenericTest , unittest .TestCase ):
192+ # Issue 16852: GenericTest can't inherit from unittest.TestCase
193+ # for test discovery purposes; CommonTest inherits from GenericTest
194+ # and is only meant to be inherited by others.
195+ pathmodule = genericpath
193196
194197# Following TestCase is not supposed to be run from test_genericpath.
195198# It is inherited by other test modules (macpath, ntpath, posixpath).
196199
197200class CommonTest (GenericTest ):
198- # The path module to be tested
199- pathmodule = None
200201 common_attributes = GenericTest .common_attributes + [
201202 # Properties
202203 'curdir' , 'pardir' , 'extsep' , 'sep' ,
@@ -328,9 +329,5 @@ def test_nonascii_abspath(self):
328329 self .test_abspath ()
329330
330331
331- def test_main ():
332- support .run_unittest (GenericTest )
333-
334-
335332if __name__ == "__main__" :
336- test_main ()
333+ unittest . main ()
0 commit comments