import unittest
import time
from Arduino import Arduino

"""
A collection of some basic tests for the Arduino library.

Extensive coverage is a bit difficult, since a positive test involves actually
connecting and issuing commands to a live Arduino, hosting any hardware
required to test a particular function. But a core of basic communication tests
should at least be maintained here.
"""


class TestBasics(unittest.TestCase):
    _ = raw_input('Plug in Arduino board w/LED at pin 13, reset, then press enter')
    board = Arduino('9600')

    def test_find(self):
        """
        Tests auto-connection/board detection
        """
        self.assertIsNotNone(self.board.port)

if __name__ == '__main__':
    unittest.main()

@@ -24,36 +24,8 @@
 time
-%0Afrom Arduino import Arduino
 %0A%0A%22%22
@@ -399,92 +399,323 @@
 e):%0A
+%0A
     
-_ = raw_input('Plug in Arduino board w/LED at pin 13, reset, then press enter')%0A
+def test_find(self):%0A        %22%22%22 Tests auto-connection/board detection. %22%22%22%0A        raw_input(%0A            'Plug in Arduino board w/LED at pin 13, reset, then press enter')%0A        from Arduino import Arduino%0A        board = None%0A        try:%0A            # This will trigger automatic port resolution.%0A        
     
@@ -734,14 +734,81 @@
 ino(
-'
 9600
-'
+)%0A        finally:%0A            if board:%0A                board.close(
 )%0A%0A 
@@ -811,36 +811,36 @@
 )%0A%0A    def test_
-find
+open
 (self):%0A        
@@ -846,54 +846,276 @@
  %22%22%22
-%0A        Tests auto-connection/board detecti
+ Tests connecting to an explicit port. %22%22%22%0A        port = raw_input(%0A            'Plug in Arduino board w/LED at pin 13, reset.%5Cn'%5C%0A            'Enter the port where the Arduino is connected, then press enter:')%0A        from Arduino import Arduino%0A        board = N
 on
+e
 %0A   
@@ -1119,19 +1119,20 @@
         
-%22%22%22
+try:
 %0A       
@@ -1136,44 +1136,112 @@
     
-self.assertIsNotNone(self.board.port
+    board = Arduino(9600, port=port)%0A        finally:%0A            if board:%0A                board.close(
 )%0A%0Ai

Add another test to explicitly connect to a serial port.