Skip to content

Commit

Permalink
adjust tests for python3 strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed May 3, 2016
1 parent 79725a4 commit 8815fe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions mpf/tests/test_Fadecandy.py
Expand Up @@ -24,10 +24,10 @@ def setUp(self):
openpixel.OpenPixelClient.send = self._send_mock
super().setUp()
color_correct = self._messages.pop(0)
color_correct_binary = 'b\'\\x00\\xff\\x00Z\\x00\\x01\\x00\\x01\''
color_correct_binary = b'\x00\xff\x00Z\x00\x01\x00\x01'
self.assertEqual(color_correct[0:len(color_correct_binary)], color_correct_binary)
correction = {"linearSlope": 1.0, "linearCutoff": 0.0, "gamma": 2.5, "whitepoint": [1.0, 1.0, 1.0]}
self.assertEqual(json.loads(color_correct[len(color_correct_binary):]), correction)
self.assertEqual(json.loads(color_correct[len(color_correct_binary):].decode()), correction)

firmware = self._messages.pop(0)
self.assertEqual(firmware, b'\x00\xff\x00\x05\x00\x01\x00\x02\x00')
Expand All @@ -47,7 +47,7 @@ def _build_message(self, channel, leds):
else:
out += chr(0) + chr(0) + chr(0)

return out
return bytes(out, 'UTF-8')

def _send_mock(self, message):
self._messages.append(message)
Expand All @@ -59,9 +59,9 @@ def assertOpenPixelLedsSent(self, leds1, leds2):
found2 = False
for message in self._messages:
if not (message == bank1 or message == bank2):
print(":".join("{:02x}".format(ord(c)) for c in message))
print(":".join("{:02x}".format(ord(c)) for c in bank1))
print(":".join("{:02x}".format(ord(c)) for c in bank2))
print(":".join("{:02x}".format(c) for c in message))
print(":".join("{:02x}".format(c) for c in bank1))
print(":".join("{:02x}".format(c) for c in bank2))
raise AssertionError("Invalid Message")
if message == bank1:
found1 = True
Expand Down
2 changes: 1 addition & 1 deletion mpf/tests/test_Openpixel.py
Expand Up @@ -37,7 +37,7 @@ def _build_message(self, channel, leds):
else:
out += chr(0) + chr(0) + chr(0)

return out
return bytes(out, 'UTF-8')

def _send_mock(self, message):
self._messages.append(message)
Expand Down

0 comments on commit 8815fe9

Please sign in to comment.