changeset 81343:3a7cd8efc19f

#16852: merge with 3.3.
author Ezio Melotti <ezio.melotti@gmail.com>
date Thu, 10 Jan 2013 03:29:45 +0200
parents be8e6b81284e (current diff) 6f71e6aa9041 (diff)
children 05183ce544be
files Lib/test/test_genericpath.py Lib/test/test_posixpath.py Misc/NEWS
diffstat 5 files changed, 16 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/test/test_genericpath.py	Wed Jan 09 19:00:26 2013 +0100
+++ b/Lib/test/test_genericpath.py	Thu Jan 10 03:29:45 2013 +0200
@@ -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,17 @@
             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 +409,5 @@
                 self.test_abspath()
 
 
-def test_main():
-    support.run_unittest(GenericTest)
-
-
 if __name__=="__main__":
-    test_main()
+    unittest.main()
--- a/Lib/test/test_macpath.py	Wed Jan 09 19:00:26 2013 +0100
+++ b/Lib/test/test_macpath.py	Thu Jan 10 03:29:45 2013 +0200
@@ -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()
--- a/Lib/test/test_ntpath.py	Wed Jan 09 19:00:26 2013 +0100
+++ b/Lib/test/test_ntpath.py	Thu Jan 10 03:29:45 2013 +0200
@@ -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()
--- a/Lib/test/test_posixpath.py	Wed Jan 09 19:00:26 2013 +0100
+++ b/Lib/test/test_posixpath.py	Thu Jan 10 03:29:45 2013 +0200
@@ -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()
--- a/Misc/NEWS	Wed Jan 09 19:00:26 2013 +0100
+++ b/Misc/NEWS	Thu Jan 10 03:29:45 2013 +0200
@@ -614,6 +614,9 @@
 
 - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host.
 
+- 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 #10646: Tests rearranged for os.samefile/samestat to check for not