title: simple linear search testing (python)
body: <p>The problem is to fix intentionally incorrect code so that pyUnit tests can be preformed. The error(s) in the code are to be found using the tests, then corrected. My last test generates an error in the code, but I cant spot it!</p>
  
  <p>given code(w/ errors)</p>
  
  <pre><code>def linear( target, list ):
  """ returns the position of target,
  if not found returns -1"""
  position = 0
  if len(list)==0:
      return -1
  
  else:
      while position &lt;= (len(list)+1):
          if target == list[position]:
              return position
          position += 1
  return -1
  </code></pre>
  
  <p>and my tests:</p>
  
  <pre><code>import unittest
  
  # import the module(s) to be tested:
  from LinearSearch import *
  
  class TestLinearSearch(unittest.TestCase):
  
  # setUp - run prior to the start of each test case
  def setUp(self):
      # initialize test fixtures
      return
  
      def test_smoke(self):
          # very simple test to insure test framework is correct
          self.assertTrue(1)
  
      # additional test_xxx methods follow....
      def test_emptyList(self):
          self.assertEqual(linear(4,[]),-1)
  
      def test_singleChar(self):
          self.assertEqual(linear(1,[1]),0)
  
      def test_isInList(self):
          self.assertEqual(linear(4,[1,2,3,4,5]),3)
  
      def test_isNotInList(self):
          self.assertEqual(linear(8,[1,2,3,4,5]),-1)
  
  
  if __name__ == '__main__':
      unittest.main()
  </code></pre>
  
  <p>the test that generates my error is the last test: "test_isNotInList(self)", it is an index out of bounds error...should be simple enough but I just need a little help.</p>