Skip to content

Commit d098ff2

Browse files
committed
Port Python 2.6 bsddb3 testdriver to Python 3.0
1 parent f15b4b7 commit d098ff2

File tree

1 file changed

+23
-60
lines changed

1 file changed

+23
-60
lines changed

Lib/test/test_bsddb3.py

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
if __name__ != '__main__':
1515
requires('bsddb')
1616

17-
import bsddb.test.test_all
17+
verbose = False
1818
if 'verbose' in sys.argv:
19-
bsddb.test.test_all.verbose = 1
19+
verbose = True
2020
sys.argv.remove('verbose')
2121

2222
if 'silent' in sys.argv: # take care of old flag, just in case
23-
bsddb.test.test_all.verbose = 0
23+
verbose = False
2424
sys.argv.remove('silent')
2525

2626

@@ -48,66 +48,29 @@ def testCheckElapsedTime(self):
4848
sys.__stdout__.flush()
4949

5050

51-
def suite():
52-
try:
53-
# this is special, it used to segfault the interpreter
54-
import bsddb.test.test_1413192
55-
finally:
56-
for f in ['xxx.db','__db.001','__db.002','__db.003','log.0000000001']:
57-
unlink(f)
58-
59-
test_modules = [
60-
'test_associate',
61-
'test_basics',
62-
'test_compat',
63-
'test_compare',
64-
'test_dbobj',
65-
'test_dbshelve',
66-
'test_dbtables',
67-
'test_env_close',
68-
'test_get_none',
69-
'test_join',
70-
'test_lock',
71-
'test_misc',
72-
'test_pickle',
73-
'test_queue',
74-
'test_recno',
75-
'test_thread',
76-
'test_sequence',
77-
'test_cursor_pget_bug',
78-
]
79-
80-
alltests = unittest.TestSuite()
81-
for name in test_modules:
82-
module = __import__("bsddb.test."+name, globals(), locals(), name)
83-
#print module,name
84-
alltests.addTest(module.test_suite())
85-
alltests.addTest(unittest.makeSuite(TimingCheck))
86-
return alltests
87-
88-
8951
# For invocation through regrtest
9052
def test_main():
91-
run_unittest(suite())
92-
db_home = os.path.join(tempfile.gettempdir(), 'db_home')
93-
# The only reason to remove db_home is in case if there is an old
94-
# one lying around. This might be by a different user, so just
95-
# ignore errors. We should always make a unique name now.
53+
from bsddb import db
54+
from bsddb.test import test_all
55+
test_all.set_test_path_prefix(os.path.join(tempfile.gettempdir(),
56+
'z-test_bsddb3-%s' %
57+
os.getpid()))
58+
# Please leave this print in, having this show up in the buildbots
59+
# makes diagnosing problems a lot easier.
60+
print(db.DB_VERSION_STRING, file=sys.stderr)
61+
print('Test path prefix: ', test_all.get_test_path_prefix(), file=sys.stderr)
9662
try:
97-
rmtree(db_home)
98-
except:
99-
pass
100-
rmtree('db_home%d' % os.getpid())
63+
run_unittest(test_all.suite(module_prefix='bsddb.test.',
64+
timing_check=TimingCheck))
65+
finally:
66+
# The only reason to remove db_home is in case if there is an old
67+
# one lying around. This might be by a different user, so just
68+
# ignore errors. We should always make a unique name now.
69+
try:
70+
test_all.remove_test_path_directory()
71+
except:
72+
pass
10173

102-
# For invocation as a script
103-
if __name__ == '__main__':
104-
from bsddb import db
105-
print('-=' * 38)
106-
print(db.DB_VERSION_STRING)
107-
print('bsddb.db.version(): %s' % (db.version(),))
108-
print('bsddb.db.__version__: %s' % db.__version__)
109-
print('bsddb.db.cvsid: %s' % db.cvsid)
110-
print('python version: %s' % sys.version)
111-
print('-=' * 38)
11274

75+
if __name__ == '__main__':
11376
test_main()

0 commit comments

Comments
 (0)