Skip to content

Commit

Permalink
More bytes/unicode py3 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
waveform80 committed Jul 2, 2016
1 parent e6f0541 commit 2e02d14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions tests/test_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_capture_bayer(camera, mode):
stream.seek(-6404096, io.SEEK_END)
else:
stream.seek(-10270208, io.SEEK_END)
assert stream.read(4) == 'BRCM'
assert stream.read(4) == b'BRCM'

def test_capture_sequence_bayer(camera, mode):
streams = [io.BytesIO() for i in range(3)]
Expand All @@ -204,7 +204,7 @@ def test_capture_sequence_bayer(camera, mode):
stream.seek(-6404096, io.SEEK_END)
else:
stream.seek(-10270208, io.SEEK_END)
assert stream.read(4) == 'BRCM'
assert stream.read(4) == b'BRCM'

def test_exif_ascii(camera, mode):
camera.exif_tags['IFD0.Artist'] = 'Me!'
Expand Down Expand Up @@ -255,5 +255,5 @@ def test_capture_bytes_filename(camera, tmpdir):
camera.capture(str(tmpdir.join('test.jpg')).encode('utf-8'))

def test_capture_bytes_format(camera, tmpdir):
camera.capture(tmpdir.join('test.jpg'), b'jpeg')
camera.capture(str(tmpdir.join('test.jpg')), b'jpeg')

8 changes: 4 additions & 4 deletions tests/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ def test_multi_res_record_len(camera, mode):
camera.wait_recording(1)
finally:
camera.stop_recording()
# output1's size should be approximately twice output2's; we give it a bit
# of leeway here (50%) in the test as waiting for an I-frame in slower
# framerates can lead to a failure otherwise
assert output1.size > (output2.size * 1.5)
# output1's size should be larger than output2's although given H.264 is
# impressively efficient we really can't say by how much!
assert output2.size > 0
assert output1.size > output2.size

class MotionTest(object):
def __init__(self, camera):
Expand Down
18 changes: 9 additions & 9 deletions tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_init():
def test_seek_tell():
stream = CircularIO(10)
assert stream.tell() == 0
stream.write('defghijklm')
stream.write(b'defghijklm')
assert stream.tell() == 10
stream.seek(0)
assert stream.tell() == 0
Expand All @@ -81,8 +81,8 @@ def test_seek_tell():

def test_read():
stream = CircularIO(10)
stream.write('abcdef')
stream.write('ghijklm')
stream.write(b'abcdef')
stream.write(b'ghijklm')
stream.seek(0)
assert stream.read(1) == b'd'
assert stream.read(4) == b'efgh'
Expand All @@ -94,8 +94,8 @@ def test_read():

def test_read1():
stream = CircularIO(10)
stream.write('abcdef')
stream.write('ghijklm')
stream.write(b'abcdef')
stream.write(b'ghijklm')
stream.seek(0)
assert stream.read1() == b'def'
stream.seek(0)
Expand Down Expand Up @@ -130,8 +130,8 @@ def test_write():

def test_truncate():
stream = CircularIO(10)
stream.write('abcdef')
stream.write('ghijklm')
stream.write(b'abcdef')
stream.write(b'ghijklm')
stream.seek(8)
stream.truncate()
stream.seek(0, io.SEEK_END)
Expand All @@ -154,7 +154,7 @@ def generate_frames(s, index=0):
for data in s:
if data == 'k':
pos += 1
yield data, PiVideoFrame(
yield data.encode('ascii'), PiVideoFrame(
index=index,
frame_type=PiVideoFrameType.key_frame,
frame_size=1,
Expand All @@ -163,7 +163,7 @@ def generate_frames(s, index=0):
timestamp=timestamp,
complete=False)
pos += 1
yield data, PiVideoFrame(
yield data.encode('ascii'), PiVideoFrame(
index=index,
frame_type={
'f': PiVideoFrameType.frame,
Expand Down

0 comments on commit 2e02d14

Please sign in to comment.