Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_dbm.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 9ae3cccfa7cd |
| children | aedd2d0dcb31 |
| rev | line source |
|---|---|
|
4647
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
1 #! /usr/bin/env python |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
2 """Test script for the dbm module |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
3 Roger E. Masse |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
4 """ |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
5 import dbm |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
6 from dbm import error |
|
4811
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
7 from test_support import verbose |
|
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
8 |
|
4647
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
9 filename= '/tmp/delete_me' |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
10 |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
11 d = dbm.open(filename, 'c') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
12 d['a'] = 'b' |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
13 d['12345678910'] = '019237410982340912840198242' |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
14 d.keys() |
|
4811
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
15 if d.has_key('a'): |
|
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
16 if verbose: |
|
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
17 print 'Test dbm keys: ', d.keys() |
|
9ae3cccfa7cd
Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4647
diff
changeset
|
18 |
|
4647
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
19 d.close() |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
20 d = dbm.open(filename, 'r') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
21 d.close() |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
22 d = dbm.open(filename, 'rw') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
23 d.close() |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
24 d = dbm.open(filename, 'w') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
25 d.close() |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
26 d = dbm.open(filename, 'n') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
27 d.close() |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
28 |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
29 try: |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
30 import os |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
31 os.unlink(filename + '.dir') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
32 os.unlink(filename + '.pag') |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
33 except: |
|
ab6374268caa
Added a test script for dbmmodule.c and added it to testall.py and
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff
changeset
|
34 pass |
