def turn(self, direction): #print "spider.turn(" + str(direction) + ")" main.turn(direction)
def test_last(self): sticks = 1 comp_takes = turn(sticks) self.assertEqual(comp_takes, 1)
def test_win_condition(self): sticks_left = [21, 17, 13, 9, 5, 1] for sticks in range(2, 20): if sticks not in sticks_left: comp_takes = turn(sticks) self.assertTrue((sticks - comp_takes) in sticks_left)
def test_right_result(self): sticks = range(4, 21) for s in sticks: comp_takes = turn(s) self.assertTrue(1 <= comp_takes <= 3)
def test_three(self): sticks = 3 comp_takes = turn(sticks) self.assertEqual(comp_takes, 2)
def test_two(self): sticks = 2 comp_takes = turn(sticks) self.assertEqual(comp_takes, 1)