]> granicus.if.org Git - python/commitdiff
#16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath now work...
authorEzio Melotti <ezio.melotti@gmail.com>
Thu, 10 Jan 2013 01:12:50 +0000 (03:12 +0200)
committerEzio Melotti <ezio.melotti@gmail.com>
Thu, 10 Jan 2013 01:12:50 +0000 (03:12 +0200)
Lib/test/test_genericpath.py
Lib/test/test_macpath.py
Lib/test/test_ntpath.py
Lib/test/test_posixpath.py
Misc/NEWS

index 08061fa81eff6cff2881ed5c48cb5ba3c06fd832..fd8bc577ca85e836d85fd05e697a3c991f7c2a66 100644 (file)
@@ -17,9 +17,7 @@ def safe_rmdir(dirname):
         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 @@ class GenericTest(unittest.TestCase):
             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 @@ class CommonTest(GenericTest):
                 self.test_abspath()
 
 
-def test_main():
-    support.run_unittest(GenericTest)
-
-
 if __name__=="__main__":
-    test_main()
+    unittest.main()
index d732e14a3a4f74558afca97f398d5f9b72e3a4ce..ae4e5640fa92daf94bb01b557bdc8989f108c6ae 100644 (file)
@@ -115,13 +115,9 @@ class MacPathTestCase(unittest.TestCase):
         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()
index 2c9dab9bb053e552e50a80b1c1eafad0d9ac012d..f8098767ceaa2c0c5c99319f8031f047de6055b8 100644 (file)
@@ -257,14 +257,10 @@ class TestNtpath(unittest.TestCase):
                     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()
index 7aca87d35ce118cc50b6a7bfef37554104b0b474..a16a957e6a799047ad607babfd24dcca4b62ced4 100644 (file)
@@ -524,14 +524,10 @@ class PosixPathTest(unittest.TestCase):
             self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
 
 
-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()
index 6ed6101635bb56135052064d66e4ce8483e85b73..1d678dc93b030a06448de26fbd48c2e5fb4b6dcd 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -408,6 +408,9 @@ Library
 Tests
 -----
 
+- Issue #16852: test_genericpath, test_posixpath, test_ntpath, and test_macpath
+  now work with unittest test discovery.  Patch by Zachary Ware.
+
 - Issue #16748: test_heapq now works with unittest test discovery.
 
 - Issue #15324: Fix regrtest parsing of --fromfile, --match, and --randomize