1. Nick Raptis
  2. pyFirmata_nickraptis_mq

Source

pyFirmata_nickraptis_mq / TestMockupInWaiting.diff

# HG changeset patch
# Parent 651f06a045e52af82b28a1544e32404c1befd7e3
tests: Add pyserial's inWaiting to mockup

diff -r 651f06a045e5 -r f240bc4e31bb pyfirmata/mockup.py
--- a/pyfirmata/mockup.py	Mon May 16 23:04:43 2011 +0300
+++ b/pyfirmata/mockup.py	Tue May 17 00:04:54 2011 +0300
@@ -12,6 +12,8 @@
     >>> s.write(chr(100))
     >>> s.write('blaat')
     >>> s.write(100000)
+    >>> s.inWaiting()
+    3
     >>> s.read(2)
     ['d', 'blaat']
     >>> s.read()
@@ -20,6 +22,8 @@
     ''
     >>> s.read(2)
     ['', '']
+    >>> s.inWaiting()
+    0
     >>> s.close()
     """
     def __init__(self, port, baudrate, timeout=0.02):
@@ -49,6 +53,9 @@
         else:
             self.append(value)
             
+    def inWaiting(self):
+        return len(self)
+
     def close(self):
         self.clear()