blob: 15ed1e471a9f8dd43fc5c2d16d6effcc5027c6ac [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
Gregory P. Smith3fd22da2007-08-28 08:05:56 +00007import test.test_support
8from test.test_support import requires, run_unittest, unlink
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +00009
Barry Warsaw0a262352002-12-30 20:53:18 +000010# When running as a script instead of within the regrtest framework, skip the
11# requires test, since it's obvious we want to run them.
Guido van Rossumb053cd82006-08-24 03:53:23 +000012if __name__ != '__main__':
Barry Warsaw0a262352002-12-30 20:53:18 +000013 requires('bsddb')
14
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000015import bsddb.test.test_all
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000016if 'verbose' in sys.argv:
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000017 bsddb.test.test_all.verbose = 1
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000018 sys.argv.remove('verbose')
19
20if 'silent' in sys.argv: # take care of old flag, just in case
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000021 bsddb.test.test_all.verbose = 0
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000022 sys.argv.remove('silent')
23
24
25def suite():
Neal Norwitz62a21122006-01-25 05:21:55 +000026 try:
27 # this is special, it used to segfault the interpreter
Martin v. Löwis32ca4422007-08-11 06:13:20 +000028 import bsddb.test.test_1413192
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000029 finally:
30 for f in ['xxx.db','__db.001','__db.002','__db.003','log.0000000001']:
Neal Norwitz14361ff2006-01-25 07:20:47 +000031 unlink(f)
Neal Norwitz62a21122006-01-25 05:21:55 +000032
Barry Warsaw0a262352002-12-30 20:53:18 +000033 test_modules = [
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000034 'test_associate',
35 'test_basics',
36 'test_compat',
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000037 'test_compare',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000038 'test_dbobj',
Barry Warsaw0a262352002-12-30 20:53:18 +000039 'test_dbshelve',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000040 'test_dbtables',
41 'test_env_close',
42 'test_get_none',
43 'test_join',
44 'test_lock',
45 'test_misc',
Gregory P. Smith3fd22da2007-08-28 08:05:56 +000046 'test_pickle',
Martin v. Löwiscccc58d2007-08-10 08:36:56 +000047 'test_queue',
48 'test_recno',
49 'test_thread',
50 'test_sequence',
51 'test_cursor_pget_bug',
Barry Warsaw0a262352002-12-30 20:53:18 +000052 ]
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000053
54 alltests = unittest.TestSuite()
55 for name in test_modules:
56 module = __import__("bsddb.test."+name, globals(), locals(), name)
Barry Warsaw0a262352002-12-30 20:53:18 +000057 #print module,name
58 alltests.addTest(module.test_suite())
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000059 return alltests
60
Barry Warsaw0a262352002-12-30 20:53:18 +000061
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000062# For invocation through regrtest
63def test_main():
Guido van Rossumd8faa362007-04-27 19:54:29 +000064 run_unittest(suite())
Barry Warsaw0a262352002-12-30 20:53:18 +000065
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000066# For invocation as a script
67if __name__ == '__main__':
68 from bsddb import db
Guido van Rossumbe19ed72007-02-09 05:37:30 +000069 print('-=' * 38)
70 print(db.DB_VERSION_STRING)
71 print('bsddb.db.version(): %s' % (db.version(),))
72 print('bsddb.db.__version__: %s' % db.__version__)
73 print('bsddb.db.cvsid: %s' % db.cvsid)
74 print('python version: %s' % sys.version)
75 print('-=' * 38)
Martin v. Löwis1c6b1a22002-11-19 17:47:07 +000076
Guido van Rossumd8faa362007-04-27 19:54:29 +000077 test_main()