Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_bsddb3.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 7641a3f0b2ec |
| children | af498ab2afb4 |
| rev | line source |
|---|---|
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
1 # Test driver for bsddb package. |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
2 """ |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
3 Run all test cases. |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
4 """ |
|
45506
55eefb43ef6f
Create a db_home directory with a unique name so multiple users can
Neal Norwitz <nnorwitz@gmail.com>
parents:
45012
diff
changeset
|
5 import os |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
6 import sys |
|
45506
55eefb43ef6f
Create a db_home directory with a unique name so multiple users can
Neal Norwitz <nnorwitz@gmail.com>
parents:
45012
diff
changeset
|
7 import tempfile |
|
45012
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
8 import time |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
9 import unittest |
|
52491
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
47353
diff
changeset
|
10 from test.test_support import (requires, verbose, run_unittest, unlink, rmtree, |
|
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
47353
diff
changeset
|
11 import_module) |
|
f4c5e3a64be2
Change more tests to use import_module for the modules that
R. David Murray <rdmurray@bitdance.com>
parents:
47353
diff
changeset
|
12 |
|
52555
7641a3f0b2ec
A few more test skips via import_module, and change import_module to
R. David Murray <rdmurray@bitdance.com>
parents:
52491
diff
changeset
|
13 # Skip test if _bsddb module was not built. |
|
7641a3f0b2ec
A few more test skips via import_module, and change import_module to
R. David Murray <rdmurray@bitdance.com>
parents:
52491
diff
changeset
|
14 import_module('_bsddb') |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
15 |
|
26877
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
16 # When running as a script instead of within the regrtest framework, skip the |
|
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
17 # requires test, since it's obvious we want to run them. |
|
41534
6c4d7678af5e
Standardize on test.test_support.run_unittest() (as opposed to a mix of run_unittest() and run_suite()). Also, add functionality to run_unittest() that admits usage of unittest.TestLoader.loadTestsFromModule().
Collin Winter <collinw@gmail.com>
parents:
38611
diff
changeset
|
18 if __name__ != '__main__': |
|
26877
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
19 requires('bsddb') |
|
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
20 |
|
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
21 verbose = False |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
22 if 'verbose' in sys.argv: |
|
26877
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
23 verbose = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
24 sys.argv.remove('verbose') |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
25 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
26 if 'silent' in sys.argv: # take care of old flag, just in case |
|
26877
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
27 verbose = False |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
28 sys.argv.remove('silent') |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
29 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 |
|
45012
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
31 class TimingCheck(unittest.TestCase): |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
32 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
33 """This class is not a real test. Its purpose is to print a message |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
34 periodically when the test runs slowly. This will prevent the buildbots |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
35 from timing out on slow machines.""" |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
36 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
37 # How much time in seconds before printing a 'Still working' message. |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
38 # Since this is run at most once between each test module, use a smaller |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
39 # interval than other tests. |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
40 _PRINT_WORKING_MSG_INTERVAL = 4 * 60 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
41 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
42 # next_time is used as a global variable that survives each instance. |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
43 # This is necessary since a new instance will be created for each test. |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
44 next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
45 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
46 def testCheckElapsedTime(self): |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
47 # Print still working message since these tests can be really slow. |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
48 now = time.time() |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
49 if self.next_time <= now: |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
50 TimingCheck.next_time = now + self._PRINT_WORKING_MSG_INTERVAL |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
51 sys.__stdout__.write(' test_bsddb3 still working, be patient...\n') |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
52 sys.__stdout__.flush() |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
53 |
|
1ff2bb5187df
Print periodic "still working" messages since this suite is slow.
Neal Norwitz <nnorwitz@gmail.com>
parents:
41534
diff
changeset
|
54 |
|
47246
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
55 # For invocation through regrtest |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
56 def test_main(): |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
57 from bsddb import db |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
58 from bsddb.test import test_all |
|
47353
4a7f3480f454
Better integration between Python testing and bsddb3
Jesus Cea <jcea@jcea.es>
parents:
47246
diff
changeset
|
59 test_all.set_test_path_prefix(os.path.join(tempfile.gettempdir(), |
|
4a7f3480f454
Better integration between Python testing and bsddb3
Jesus Cea <jcea@jcea.es>
parents:
47246
diff
changeset
|
60 'z-test_bsddb3-%s' % |
|
4a7f3480f454
Better integration between Python testing and bsddb3
Jesus Cea <jcea@jcea.es>
parents:
47246
diff
changeset
|
61 os.getpid())) |
|
47246
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
62 # Please leave this print in, having this show up in the buildbots |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
63 # makes diagnosing problems a lot easier. |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
64 print >>sys.stderr, db.DB_VERSION_STRING |
|
47353
4a7f3480f454
Better integration between Python testing and bsddb3
Jesus Cea <jcea@jcea.es>
parents:
47246
diff
changeset
|
65 print >>sys.stderr, 'Test path prefix: ', test_all.get_test_path_prefix() |
|
47246
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
66 try: |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
67 run_unittest(test_all.suite(module_prefix='bsddb.test.', |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
68 timing_check=TimingCheck)) |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
69 finally: |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
70 # The only reason to remove db_home is in case if there is an old |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
71 # one lying around. This might be by a different user, so just |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
72 # ignore errors. We should always make a unique name now. |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
73 try: |
|
47353
4a7f3480f454
Better integration between Python testing and bsddb3
Jesus Cea <jcea@jcea.es>
parents:
47246
diff
changeset
|
74 test_all.remove_test_path_directory() |
|
47246
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
75 except: |
|
71fdbcd7baa9
* Give the test_bsddb3 tests a unique temporary directory to run their
Gregory P. Smith <greg@mad-scientist.com>
parents:
46990
diff
changeset
|
76 pass |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
77 |
|
26877
120afba2dbf6
Add some missing tests. Should now test everything that pybsddb's
Barry Warsaw <barry@python.org>
parents:
26387
diff
changeset
|
78 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
79 if __name__ == '__main__': |
|
41534
6c4d7678af5e
Standardize on test.test_support.run_unittest() (as opposed to a mix of run_unittest() and run_suite()). Also, add functionality to run_unittest() that admits usage of unittest.TestLoader.loadTestsFromModule().
Collin Winter <collinw@gmail.com>
parents:
38611
diff
changeset
|
80 test_main() |
