@@ -88,9 +88,9 @@ def test02(self):
8888 col1 = 'but can it fly?'
8989 col2 = 'Species'
9090 testinfo = [
91- {col0 : pickle .dumps (8 , 1 ), col1 : 'no' , col2 : 'Penguin' },
92- {col0 : pickle .dumps (- 1 , 1 ), col1 : 'no' , col2 : 'Turkey' },
93- {col0 : pickle .dumps (9 , 1 ), col1 : 'yes' , col2 : 'SR-71A Blackbird' }
91+ {col0 : pickle .dumps (8 , 1 ), col1 : b 'no' , col2 : b 'Penguin' },
92+ {col0 : pickle .dumps (- 1 , 1 ), col1 : b 'no' , col2 : b 'Turkey' },
93+ {col0 : pickle .dumps (9 , 1 ), col1 : b 'yes' , col2 : b 'SR-71A Blackbird' }
9494 ]
9595
9696 try :
@@ -150,22 +150,22 @@ def test03(self):
150150 pass
151151
152152 self .tdb .Insert (tabname ,
153- {'a' : '42' ,
154- 'b' : " bad" ,
155- 'c' : " meep" ,
156- 'e' : 'Fuzzy wuzzy was a bear' })
153+ {'a' : b '42' ,
154+ 'b' : b' bad' ,
155+ 'c' : b' meep' ,
156+ 'e' : b 'Fuzzy wuzzy was a bear' })
157157 self .tdb .Insert (tabname ,
158- {'a' : '581750' ,
159- 'b' : " good" ,
160- 'd' : " bla" ,
161- 'c' : " black" ,
162- 'e' : 'fuzzy was here' })
158+ {'a' : b '581750' ,
159+ 'b' : b' good' ,
160+ 'd' : b' bla' ,
161+ 'c' : b' black' ,
162+ 'e' : b 'fuzzy was here' })
163163 self .tdb .Insert (tabname ,
164- {'a' : '800000' ,
165- 'b' : " good" ,
166- 'd' : " bla" ,
167- 'c' : " black" ,
168- 'e' : 'Fuzzy wuzzy is a bear' })
164+ {'a' : b '800000' ,
165+ 'b' : b' good' ,
166+ 'd' : b' bla' ,
167+ 'c' : b' black' ,
168+ 'e' : b 'Fuzzy wuzzy is a bear' })
169169
170170 if verbose :
171171 self .tdb ._db_print ()
@@ -202,19 +202,19 @@ def test04_MultiCondSelect(self):
202202
203203 try :
204204 self .tdb .Insert (tabname ,
205- {'a' : "" ,
205+ {'a' : b "" ,
206206 'e' : pickle .dumps ([{4 :5 , 6 :7 }, 'foo' ], 1 ),
207- 'f' : "Zero" })
207+ 'f' : b "Zero" })
208208 self .fail ("exception not raised" )
209209 except dbtables .TableDBError :
210210 pass
211211
212- self .tdb .Insert (tabname , {'a' : "A" , 'b' : "B" , 'c' : "C" , 'd' : "D " ,
213- 'e' : "E" })
214- self .tdb .Insert (tabname , {'a' : "-A" , 'b' : "-B" , 'c' : "-C" , 'd' : "-D " ,
215- 'e' : "-E" })
216- self .tdb .Insert (tabname , {'a' : "A-" , 'b' : "B-" , 'c' : "C-" , 'd' : "D -" ,
217- 'e' : "E-" })
212+ self .tdb .Insert (tabname , {'a' : b "A" , 'b' : b "B" , 'c' : b"C " ,
213+ 'd' : b"D" , ' e' : b "E" })
214+ self .tdb .Insert (tabname , {'a' : b "-A" , 'b' : b "-B" , 'c' : b "-C" ,
215+ 'd' : b"-D" , ' e' : b "-E" })
216+ self .tdb .Insert (tabname , {'a' : b "A-" , 'b' : b "B-" , 'c' : b"C -" ,
217+ 'd' : b"D-" , ' e' : b "E-" })
218218
219219 if verbose :
220220 self .tdb ._db_print ()
@@ -239,39 +239,39 @@ def test_CreateOrExtend(self):
239239 tabname , ['name' , 'taste' , 'filling' , 'alcohol content' , 'price' ])
240240 try :
241241 self .tdb .Insert (tabname ,
242- {'taste' : 'crap' ,
243- 'filling' : 'no' ,
244- 'is it Guinness?' : 'no' })
242+ {'taste' : b 'crap' ,
243+ 'filling' : b 'no' ,
244+ 'is it Guinness?' : b 'no' })
245245 self .fail ("Insert should've failed due to bad column name" )
246246 except :
247247 pass
248248 self .tdb .CreateOrExtendTable (tabname ,
249249 ['name' , 'taste' , 'is it Guinness?' ])
250250
251251 # these should both succeed as the table should contain the union of both sets of columns.
252- self .tdb .Insert (tabname , {'taste' : 'crap' , 'filling' : 'no' ,
253- 'is it Guinness?' : 'no' })
254- self .tdb .Insert (tabname , {'taste' : 'great' , 'filling' : 'yes' ,
255- 'is it Guinness?' : 'yes' ,
256- 'name' : 'Guinness' })
252+ self .tdb .Insert (tabname , {'taste' : b 'crap' , 'filling' : b 'no' ,
253+ 'is it Guinness?' : b 'no' })
254+ self .tdb .Insert (tabname , {'taste' : b 'great' , 'filling' : b 'yes' ,
255+ 'is it Guinness?' : b 'yes' ,
256+ 'name' : b 'Guinness' })
257257
258258
259259 def test_CondObjs (self ):
260260 tabname = "test_CondObjs"
261261
262262 self .tdb .CreateTable (tabname , ['a' , 'b' , 'c' , 'd' , 'e' , 'p' ])
263263
264- self .tdb .Insert (tabname , {'a' : "the letter A" ,
265- 'b' : "the letter B" ,
266- 'c' : "is for cookie" })
267- self .tdb .Insert (tabname , {'a' : "is for aardvark" ,
268- 'e' : "the letter E" ,
269- 'c' : "is for cookie" ,
270- 'd' : "is for dog" })
271- self .tdb .Insert (tabname , {'a' : "the letter A" ,
272- 'e' : "the letter E" ,
273- 'c' : "is for cookie" ,
274- 'p' : "is for Python" })
264+ self .tdb .Insert (tabname , {'a' : b "the letter A" ,
265+ 'b' : b "the letter B" ,
266+ 'c' : b "is for cookie" })
267+ self .tdb .Insert (tabname , {'a' : b "is for aardvark" ,
268+ 'e' : b "the letter E" ,
269+ 'c' : b "is for cookie" ,
270+ 'd' : b "is for dog" })
271+ self .tdb .Insert (tabname , {'a' : b "the letter A" ,
272+ 'e' : b "the letter E" ,
273+ 'c' : b "is for cookie" ,
274+ 'p' : b "is for Python" })
275275
276276 values = self .tdb .Select (
277277 tabname , ['p' , 'e' ],
@@ -309,8 +309,8 @@ def test_Delete(self):
309309 # fail if it encountered any rows that did not have values in
310310 # every column.
311311 # Hunted and Squashed by <Donwulff> (Jukka Santala - [email protected] ) 312- self .tdb .Insert (tabname , {'x' : 'X1' , 'y' :'Y1' })
313- self .tdb .Insert (tabname , {'x' : 'X2' , 'y' :'Y2' , 'z' : 'Z2' })
312+ self .tdb .Insert (tabname , {'x' : b 'X1' , 'y' :b 'Y1' })
313+ self .tdb .Insert (tabname , {'x' : b 'X2' , 'y' :b 'Y2' , 'z' : b 'Z2' })
314314
315315 self .tdb .Delete (tabname , conditions = {'x' : dbtables .PrefixCond ('X' )})
316316 values = self .tdb .Select (tabname , ['y' ],
@@ -321,18 +321,18 @@ def test_Modify(self):
321321 tabname = "test_Modify"
322322 self .tdb .CreateTable (tabname , ['Name' , 'Type' , 'Access' ])
323323
324- self .tdb .Insert (tabname , {'Name' : 'Index to MP3 files.doc' ,
325- 'Type' : 'Word' , 'Access' : '8' })
326- self .tdb .Insert (tabname , {'Name' : 'Nifty.MP3' , 'Access' : '1' })
327- self .tdb .Insert (tabname , {'Type' : 'Unknown' , 'Access' : '0' })
324+ self .tdb .Insert (tabname , {'Name' : b 'Index to MP3 files.doc' ,
325+ 'Type' : b 'Word' , 'Access' : b '8' })
326+ self .tdb .Insert (tabname , {'Name' : b 'Nifty.MP3' , 'Access' : b '1' })
327+ self .tdb .Insert (tabname , {'Type' : b 'Unknown' , 'Access' : b '0' })
328328
329329 def set_type (type ):
330330 if type == None :
331- return 'MP3'
331+ return b 'MP3'
332332 return type
333333
334334 def increment_access (count ):
335- return str (int (count )+ 1 )
335+ return bytes ( str (int (count )+ 1 ) )
336336
337337 def remove_value (value ):
338338 return None
@@ -350,7 +350,7 @@ def remove_value(value):
350350 try :
351351 self .tdb .Modify (tabname ,
352352 conditions = {'Name' : dbtables .LikeCond ('%' )},
353- mappings = {'Access' : 'What is your quest?' })
353+ mappings = {'Access' : b 'What is your quest?' })
354354 except TypeError :
355355 # success, the string value in mappings isn't callable
356356 pass
0 commit comments