Source

pyFirmata_nickraptis_mq / TestFirmware7bit.diff

# HG changeset patch
# Parent f240bc4e31bba4a706a44ae59b36f022081c0aad
tests: Updated Firmware tests for 7bit bytes

diff -r f240bc4e31bb -r 6afee073fe8a tests.py
--- a/tests.py	Tue May 17 00:04:54 2011 +0300
+++ b/tests.py	Tue May 17 00:06:21 2011 +0300
@@ -58,7 +58,9 @@
         
     def test_handle_report_firmware(self):
         self.assertEqual(self.board.firmware, None)
-        data = [2, 1] + [ord(x) for x in 'Firmware_name']
+        data = [2, 1]
+        for x in 'Firmware_name':
+            data += [ord(x), 0]
         self.board._handle_report_firmware(*data)
         self.assertEqual(self.board.firmware, 'Firmware_name')
         self.assertEqual(self.board.firmata_version, (2, 1))
@@ -123,8 +125,10 @@
         msg = [chr(pyfirmata.START_SYSEX), 
                chr(pyfirmata.REPORT_FIRMWARE), 
                chr(2), 
-               chr(1)] + [i for i in 'Firmware_name'] + \
-              [chr(pyfirmata.END_SYSEX)]
+               chr(1)]
+        for i in 'Firmware_name':
+            msg += [i, chr(0)]
+        msg += [chr(pyfirmata.END_SYSEX)]
         self.board.sp.write(msg)
         self.board.iterate()
         self.assertEqual(self.board.firmware, 'Firmware_name')
@@ -165,7 +169,9 @@
         self.assert_serial(*sysex)
         
     def test_receive_sysex_message(self):
-        sysex = (chr(0xF0), chr(0x79), chr(2), chr(1), 'a', 'b', 'c', chr(0xF7))
+        sysex = (chr(0xF0), chr(0x79), chr(2), chr(1),
+         'a', chr(0), 'b', chr(0), 'c', chr(0),
+         chr(0xF7))
         self.board.sp.write(sysex)
         while len(self.board.sp):
             self.board.iterate()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.