1414# limitations under the License.
1515"""Tests for adb."""
1616
17- import cStringIO
17+ import io
1818import struct
1919import unittest
2020
@@ -159,7 +159,7 @@ def _MakeSyncHeader(cls, command, *int_parts):
159159
160160 @classmethod
161161 def _MakeWriteSyncPacket (cls , command , data = '' , size = None ):
162- return cls ._MakeSyncHeader (command , size or len (data )) + data
162+ return cls ._MakeSyncHeader (command , size or len (data )) + data . encode ( "ascii" )
163163
164164 @classmethod
165165 def _ExpectSyncCommand (cls , write_commands , read_commands ):
@@ -180,7 +180,7 @@ def _ExpectSyncCommand(cls, write_commands, read_commands):
180180 return usb
181181
182182 def testPush (self ):
183- filedata = 'alo there, govnah'
183+ filedata = u 'alo there, govnah'
184184 mtime = 100
185185
186186 send = [
@@ -189,10 +189,10 @@ def testPush(self):
189189 self ._MakeWriteSyncPacket ('DONE' , size = mtime ),
190190 ]
191191 data = 'OKAY\0 \0 \0 \0 '
192- usb = self ._ExpectSyncCommand (['' .join (send )], [data ])
192+ usb = self ._ExpectSyncCommand ([b '' .join (send )], [data ])
193193
194194 adb_commands = self ._Connect (usb )
195- adb_commands .Push (cStringIO .StringIO (filedata ), '/data' , mtime = mtime )
195+ adb_commands .Push (io .StringIO (filedata ), '/data' , mtime = mtime )
196196
197197 def testPull (self ):
198198 filedata = "g'ddayta, govnah"
@@ -202,7 +202,7 @@ def testPull(self):
202202 self ._MakeWriteSyncPacket ('DATA' , filedata ),
203203 self ._MakeWriteSyncPacket ('DONE' ),
204204 ]
205- usb = self ._ExpectSyncCommand ([recv ], ['' .join (data )])
205+ usb = self ._ExpectSyncCommand ([recv ], [b '' .join (data )])
206206 adb_commands = self ._Connect (usb )
207207 self .assertEqual (filedata , adb_commands .Pull ('/data' ))
208208
0 commit comments