blob: dcc7c43500a1a4a1bdf23c7112fced57c43403b1 [file] [log] [blame]
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00001# Test driver for bsddb package.
2"""
3Run all test cases.
4"""
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00005import sys
6import unittest
Neal Norwitz14361ff2006-01-25 07:20:47 +00007from test.test_support import requires, verbose, run_suite, unlink
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00008
Barry Warsaw0a262352002-12-30 20:53:18 +00009# When running as a script instead of within the regrtest framework, skip the
10# requires test, since it's obvious we want to run them.
11if __name__ <> '__main__':
12 requires('bsddb')
13
14verbose = False
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000015if 'verbose' in sys.argv:
Barry Warsaw0a262352002-12-30 20:53:18 +000016 verbose = True
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000017 sys.argv.remove('verbose')
18
19if 'silent' in sys.argv: # take care of old flag, just in case
Barry Warsaw0a262352002-12-30 20:53:18 +000020 verbose = False
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000021 sys.argv.remove('silent')
22
23
24def suite():
Neal Norwitz62a21122006-01-25 05:21:55 +000025 try:
26 # this is special, it used to segfault the interpreter
27 import bsddb.test.test_1413192
28 except:
Neal Norwitz14361ff2006-01-25 07:20:47 +000029 for f in ['__db.001', '__db.002', '__db.003', 'log.0000000001']:
30 unlink(f)
Neal Norwitz62a21122006-01-25 05:21:55 +000031
Barry Warsaw0a262352002-12-30 20:53:18 +000032 test_modules = [
33 'test_associate',
34 'test_basics',
35 'test_compat',
36 'test_dbobj',
37 'test_dbshelve',
38 'test_dbtables',
39 'test_env_close',
40 'test_get_none',
41 'test_join',
42 'test_lock',
43 'test_misc',
44 'test_queue',
45 'test_recno',
46 'test_thread',
Gregory P. Smithf0547d02006-06-05 17:38:04 +000047 'test_sequence',
Barry Warsaw0a262352002-12-30 20:53:18 +000048 ]
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000049
50 alltests = unittest.TestSuite()
51 for name in test_modules:
52 module = __import__("bsddb.test."+name, globals(), locals(), name)
Barry Warsaw0a262352002-12-30 20:53:18 +000053 #print module,name
54 alltests.addTest(module.test_suite())
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000055 return alltests
56
Barry Warsaw0a262352002-12-30 20:53:18 +000057
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000058# For invocation through regrtest
59def test_main():
60 tests = suite()
61 run_suite(tests)
62
Barry Warsaw0a262352002-12-30 20:53:18 +000063
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000064# For invocation as a script
65if __name__ == '__main__':
66 from bsddb import db
67 print '-=' * 38
68 print db.DB_VERSION_STRING
Barry Warsaw0a262352002-12-30 20:53:18 +000069 print 'bsddb.db.version(): %s' % (db.version(),)
70 print 'bsddb.db.__version__: %s' % db.__version__
71 print 'bsddb.db.cvsid: %s' % db.cvsid
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000072 print 'python version: %s' % sys.version
73 print '-=' * 38
74
Barry Warsaw0a262352002-12-30 20:53:18 +000075 unittest.main(defaultTest='suite')