[Python-checkins] cpython (merge 3.3 -> default): #17082: merge with 3.3.

ezio.melotti python-checkins at python.org
Fri Mar 1 10:25:02 CET 2013


http://hg.python.org/cpython/rev/e35c053cc4ec
changeset:   82434:e35c053cc4ec
parent:      82432:e222f24837dd
parent:      82433:b62317fe1a22
user:        Ezio Melotti <ezio.melotti at gmail.com>
date:        Fri Mar 01 11:24:42 2013 +0200
summary:
  #17082: merge with 3.3.

files:
  Lib/test/test_dbm.py      |  20 ++++++++++----------
  Lib/test/test_dbm_dumb.py |  10 +---------
  Lib/test/test_dbm_gnu.py  |   7 ++-----
  Lib/test/test_dbm_ndbm.py |   5 +----
  Misc/NEWS                 |   3 +++
  5 files changed, 17 insertions(+), 28 deletions(-)


diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -34,7 +34,7 @@
         test.support.unlink(f)
 
 
-class AnyDBMTestCase(unittest.TestCase):
+class AnyDBMTestCase:
     _dict = {'0': b'',
              'a': b'Python:',
              'b': b'Programming',
@@ -119,10 +119,6 @@
 
 
 class WhichDBTestCase(unittest.TestCase):
-    # Actual test methods are added to namespace after class definition.
-    def __init__(self, *args):
-        unittest.TestCase.__init__(self, *args)
-
     def test_whichdb(self):
         for module in dbm_iterator():
             # Check whether whichdb correctly guesses module name
@@ -169,12 +165,16 @@
         self.d.close()
 
 
-def test_main():
-    classes = [WhichDBTestCase]
+def load_tests(loader, tests, pattern):
+    classes = []
     for mod in dbm_iterator():
-        classes.append(type("TestCase-" + mod.__name__, (AnyDBMTestCase,),
+        classes.append(type("TestCase-" + mod.__name__,
+                            (AnyDBMTestCase, unittest.TestCase),
                             {'module': mod}))
-    test.support.run_unittest(*classes)
+    suites = [unittest.makeSuite(c) for c in classes]
+
+    tests.addTests(suites)
+    return tests
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
diff --git a/Lib/test/test_dbm_dumb.py b/Lib/test/test_dbm_dumb.py
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -29,9 +29,6 @@
              '\u00fc'.encode('utf-8') : b'!',
              }
 
-    def __init__(self, *args):
-        unittest.TestCase.__init__(self, *args)
-
     def test_dumbdbm_creation(self):
         f = dumbdbm.open(_fname, 'c')
         self.assertEqual(list(f.keys()), [])
@@ -195,11 +192,6 @@
     def setUp(self):
         _delete_files()
 
-def test_main():
-    try:
-        support.run_unittest(DumbDBMTestCase)
-    finally:
-        _delete_files()
 
 if __name__ == "__main__":
-    test_main()
+    unittest.main()
diff --git a/Lib/test/test_dbm_gnu.py b/Lib/test/test_dbm_gnu.py
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -2,7 +2,7 @@
 gdbm = support.import_module("dbm.gnu") #skip if not supported
 import unittest
 import os
-from test.support import verbose, TESTFN, run_unittest, unlink
+from test.support import verbose, TESTFN, unlink
 
 
 filename = TESTFN
@@ -81,8 +81,5 @@
         self.assertTrue(size1 > size2 >= size0)
 
 
-def test_main():
-    run_unittest(TestGdbm)
-
 if __name__ == '__main__':
-    test_main()
+    unittest.main()
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -36,8 +36,5 @@
             except error:
                 self.fail()
 
-def test_main():
-    support.run_unittest(DbmTestCase)
-
 if __name__ == '__main__':
-    test_main()
+    unittest.main()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -896,6 +896,9 @@
 
 - Issue #16836: Enable IPv6 support even if IPv6 is disabled on the build host.
 
+- Issue #17082: test_dbm* now work with unittest test discovery.
+  Patch by Zachary Ware.
+
 - Issue #17079: test_ctypes now works with unittest test discovery.
   Patch by Zachary Ware.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list