summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-01 09:24:42 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-01 09:24:42 (GMT)
commitc0b64663d940d717c2b75f94c398956ffea3e6f4 (patch)
tree0b429c78eb4e748592ecef51af435b30cdffce27 /Lib
parent6cc46d35f1335e513238ba831df9d82ddc81b9d9 (diff)
parentf79493bf9ebb191f06083fdcd0bce4626641b4ac (diff)
downloadcpython-c0b64663d940d717c2b75f94c398956ffea3e6f4.zip
cpython-c0b64663d940d717c2b75f94c398956ffea3e6f4.tar.gz
cpython-c0b64663d940d717c2b75f94c398956ffea3e6f4.tar.bz2
#17082: merge with 3.3.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dbm.py20
-rw-r--r--Lib/test/test_dbm_dumb.py10
-rwxr-xr-xLib/test/test_dbm_gnu.py7
-rwxr-xr-xLib/test/test_dbm_ndbm.py5
4 files changed, 14 insertions, 28 deletions
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 95301bf..e02fa75 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -34,7 +34,7 @@ def delete_files():
test.support.unlink(f)
-class AnyDBMTestCase(unittest.TestCase):
+class AnyDBMTestCase:
_dict = {'0': b'',
'a': b'Python:',
'b': b'Programming',
@@ -119,10 +119,6 @@ class AnyDBMTestCase(unittest.TestCase):
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 @@ class WhichDBTestCase(unittest.TestCase):
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
index 6b981c4..e233929 100644
--- a/Lib/test/test_dbm_dumb.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -29,9 +29,6 @@ class DumbDBMTestCase(unittest.TestCase):
'\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 @@ class DumbDBMTestCase(unittest.TestCase):
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
index 30a39f7..bf62946 100755
--- a/Lib/test/test_dbm_gnu.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -2,7 +2,7 @@ from test import support
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 @@ class TestGdbm(unittest.TestCase):
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
index 00dcbd2..f9d3bef 100755
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -36,8 +36,5 @@ class DbmTestCase(unittest.TestCase):
except error:
self.fail()
-def test_main():
- support.run_unittest(DbmTestCase)
-
if __name__ == '__main__':
- test_main()
+ unittest.main()