@@ -21,13 +21,13 @@ def _delete_files():
2121 pass
2222
2323class AnyDBMTestCase (unittest .TestCase ):
24- _dict = {str8 ( '0' ) : b'' ,
25- str8 ( 'a' ) : b'Python:' ,
26- str8 ( 'b' ) : b'Programming' ,
27- str8 ( 'c' ) : b'the' ,
28- str8 ( 'd' ) : b'way' ,
29- str8 ( 'f' ) : b'Guido' ,
30- str8 ( 'g' ) : b'intended' ,
24+ _dict = {'0' : b'' ,
25+ 'a' : b'Python:' ,
26+ 'b' : b'Programming' ,
27+ 'c' : b'the' ,
28+ 'd' : b'way' ,
29+ 'f' : b'Guido' ,
30+ 'g' : b'intended' ,
3131 }
3232
3333 def __init__ (self , * args ):
@@ -37,14 +37,14 @@ def test_anydbm_creation(self):
3737 f = anydbm .open (_fname , 'c' )
3838 self .assertEqual (list (f .keys ()), [])
3939 for key in self ._dict :
40- f [key ] = self ._dict [key ]
40+ f [key . encode ( "ascii" ) ] = self ._dict [key ]
4141 self .read_helper (f )
4242 f .close ()
4343
4444 def test_anydbm_modification (self ):
4545 self .init_db ()
4646 f = anydbm .open (_fname , 'c' )
47- self ._dict [str8 ( 'g' ) ] = f [str8 ( 'g' ) ] = b"indented"
47+ self ._dict ['g' ] = f [b 'g' ] = b"indented"
4848 self .read_helper (f )
4949 f .close ()
5050
@@ -63,16 +63,16 @@ def test_anydbm_keys(self):
6363 def read_helper (self , f ):
6464 keys = self .keys_helper (f )
6565 for key in self ._dict :
66- self .assertEqual (self ._dict [key ], f [key ])
66+ self .assertEqual (self ._dict [key ], f [key . encode ( "ascii" ) ])
6767
6868 def init_db (self ):
6969 f = anydbm .open (_fname , 'n' )
7070 for k in self ._dict :
71- f [k ] = self ._dict [k ]
71+ f [k . encode ( "ascii" ) ] = self ._dict [k ]
7272 f .close ()
7373
7474 def keys_helper (self , f ):
75- keys = sorted (f .keys ())
75+ keys = sorted (k . decode ( "ascii" ) for k in f .keys ())
7676 dkeys = sorted (self ._dict .keys ())
7777 self .assertEqual (keys , dkeys )
7878 return keys
0 commit comments