1
1
###########################################################################
2
2
# Common tests
3
3
###########################################################################
4
+ import os
5
+
4
6
from .utils import assert_
5
7
6
8
@@ -26,6 +28,49 @@ def test_ctypes():
26
28
absolute = full .absoluteURL
27
29
assert_ (absolute .description == "https://beeware.org/contributing" )
28
30
31
+ def test_dbm ():
32
+ "The DBM module is accessible"
33
+ import dbm
34
+
35
+ cache_name = f'{ os .path .dirname (__file__ )} /dbm'
36
+ try :
37
+ with dbm .open (cache_name , 'c' ) as db :
38
+ db ['hello' ] = 'world'
39
+
40
+ assert_ (db ['hello' ] == b'world' )
41
+ finally :
42
+ os .remove (f'{ cache_name } .db' )
43
+
44
+
45
+ def test_dbm_dumb ():
46
+ "The dumb DBM module has been compiled and works"
47
+ from dbm import dumb as ddbm
48
+
49
+ cache_name = f'{ os .path .dirname (__file__ )} /ddbm'
50
+ try :
51
+ with ddbm .open (cache_name , 'c' ) as db :
52
+ db ['hello' ] = 'world'
53
+
54
+ assert_ (db ['hello' ] == b'world' )
55
+ finally :
56
+ os .remove (f'{ cache_name } .bak' )
57
+ os .remove (f'{ cache_name } .dat' )
58
+ os .remove (f'{ cache_name } .dir' )
59
+
60
+
61
+ def test_dbm_ndbm ():
62
+ "The ndbm DBM module has been compiled and works"
63
+ from dbm import ndbm
64
+
65
+ cache_name = f'{ os .path .dirname (__file__ )} /ndbm'
66
+ try :
67
+ with ndbm .open (cache_name , 'c' ) as db :
68
+ db ['hello' ] = 'world'
69
+
70
+ assert_ (db ['hello' ] == b'world' )
71
+ finally :
72
+ os .remove (f'{ cache_name } .db' )
73
+
29
74
30
75
def test_decimal ():
31
76
"The decimal module works"
0 commit comments