mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
#17082: test_dbm* now work with unittest test discovery. Patch by Zachary Ware.
This commit is contained in:
parent
520378f81d
commit
f79493bf9e
5 changed files with 17 additions and 28 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue