Esempio n. 1
0
 def test_Iteration_Empty(self):
    """Attempts to iterate over no items returns no items"""
    x=Chooser([])
    
    try:
       x.getCurrentChoice()
       self.fail()
    except IndexError:
       self.assert_(True, "Can't iterate over empty")
Esempio n. 2
0
    def test_Iteration_Empty(self):
        """Attempts to iterate over no items returns no items"""
        x = Chooser([])

        try:
            x.getCurrentChoice()
            self.fail()
        except IndexError:
            self.assert_(True, "Can't iterate over empty")
Esempio n. 3
0
 def test_Iterate_gotoFirst(self):
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    x.gotoNext()
    x.gotoNext()
    self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
    x.gotoFirst()
    self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
Esempio n. 4
0
    def test_Iterate_gotoFirst(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        x.gotoNext()
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoFirst()
        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
Esempio n. 5
0
 def test_Iteration_backwardsPastStart(self):
    """Backstepping past the start of the set still returns the first item"""
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is first item")
    
    x.gotoPrev()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is still first item")
Esempio n. 6
0
    def test_Iteration_backwardsPastStart(self):
        """Backstepping past the start of the set still returns the first item"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0], "Current choice is first item")

        x.gotoPrev()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0],
                     "Current choice is still first item")
Esempio n. 7
0
   def test_Iteration_iteratePastEnd(self):
      """Advancing past the end of the set still returns the last item"""
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)
      
      x.gotoNext()
      x.gotoNext()
      
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")

      x.gotoNext()
         
      result = x.getCurrentChoice()
      self.assert_(result == fruitlist[2], "Current choice is 3rd item")
Esempio n. 8
0
    def test_Iteration_iteratePastEnd(self):
        """Advancing past the end of the set still returns the last item"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        x.gotoNext()
        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
Esempio n. 9
0
    def test_Iteration_iterateForwards(self):
        """Iterating forwards advances forwards through the set"""
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0], "Current choice is first item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[0],
                     "Current choice is still first item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1], "Current choice is second item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[1],
                     "Current choice is still second item")

        x.gotoNext()

        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2], "Current choice is 3rd item")
        result = x.getCurrentChoice()
        self.assert_(result == fruitlist[2],
                     "Current choice is still 3rd item")
Esempio n. 10
0
   def test_Iterate_forwardsBackwardsForwards(self):
      fruitlist = ["apple","banana","cherry"]
      x=Chooser(fruitlist)

      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[2], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
      x.gotoPrev()
      self.assert_(x.getCurrentChoice() == fruitlist[0], "Current choice is correct")
      x.gotoNext()
      self.assert_(x.getCurrentChoice() == fruitlist[1], "Current choice is correct")
Esempio n. 11
0
    def test_Iterate_forwardsBackwardsForwards(self):
        fruitlist = ["apple", "banana", "cherry"]
        x = Chooser(fruitlist)

        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[2],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
        x.gotoPrev()
        self.assert_(x.getCurrentChoice() == fruitlist[0],
                     "Current choice is correct")
        x.gotoNext()
        self.assert_(x.getCurrentChoice() == fruitlist[1],
                     "Current choice is correct")
Esempio n. 12
0
 def test_Iteration_iterateForwards(self):
    """Iterating forwards advances forwards through the set"""
    fruitlist = ["apple","banana","cherry"]
    x=Chooser(fruitlist)
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is first item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[0], "Current choice is still first item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is second item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[1], "Current choice is still second item")
    
    x.gotoNext()
    
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is 3rd item")
    result = x.getCurrentChoice()
    self.assert_(result == fruitlist[2], "Current choice is still 3rd item")