1 # Test driver for bsddb package.
10 from test
.test_support
import requires
, run_unittest
, import_module
12 # Skip test if _bsddb module was not built.
13 import_module('_bsddb')
14 # Silence Py3k warning
15 import_module('bsddb', deprecated
=True)
17 # When running as a script instead of within the regrtest framework, skip the
18 # requires test, since it's obvious we want to run them.
19 if __name__
!= '__main__':
23 if 'verbose' in sys
.argv
:
25 sys
.argv
.remove('verbose')
27 if 'silent' in sys
.argv
: # take care of old flag, just in case
29 sys
.argv
.remove('silent')
32 class TimingCheck(unittest
.TestCase
):
34 """This class is not a real test. Its purpose is to print a message
35 periodically when the test runs slowly. This will prevent the buildbots
36 from timing out on slow machines."""
38 # How much time in seconds before printing a 'Still working' message.
39 # Since this is run at most once between each test module, use a smaller
40 # interval than other tests.
41 _PRINT_WORKING_MSG_INTERVAL
= 4 * 60
43 # next_time is used as a global variable that survives each instance.
44 # This is necessary since a new instance will be created for each test.
45 next_time
= time
.time() + _PRINT_WORKING_MSG_INTERVAL
47 def testCheckElapsedTime(self
):
48 # Print still working message since these tests can be really slow.
50 if self
.next_time
<= now
:
51 TimingCheck
.next_time
= now
+ self
._PRINT
_WORKING
_MSG
_INTERVAL
52 sys
.__stdout
__.write(' test_bsddb3 still working, be patient...\n')
53 sys
.__stdout
__.flush()
56 # For invocation through regrtest
59 from bsddb
.test
import test_all
60 test_all
.set_test_path_prefix(os
.path
.join(tempfile
.gettempdir(),
63 # Please leave this print in, having this show up in the buildbots
64 # makes diagnosing problems a lot easier.
65 print >>sys
.stderr
, db
.DB_VERSION_STRING
66 print >>sys
.stderr
, 'Test path prefix: ', test_all
.get_test_path_prefix()
68 run_unittest(test_all
.suite(module_prefix
='bsddb.test.',
69 timing_check
=TimingCheck
))
71 # The only reason to remove db_home is in case if there is an old
72 # one lying around. This might be by a different user, so just
73 # ignore errors. We should always make a unique name now.
75 test_all
.remove_test_path_directory()
80 if __name__
== '__main__':