#16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work with unittest test discovery. Patch by Zachary Ware.
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 08061fa..fd8bc57 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -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 = []
@@ -190,13 +188,16 @@
support.unlink(support.TESTFN)
safe_rmdir(support.TESTFN)
+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',
@@ -328,9 +329,5 @@
self.test_abspath()
-def test_main():
- support.run_unittest(GenericTest)
-
-
if __name__=="__main__":
- test_main()
+ unittest.main()