def test_hand_keep_roll(self): name = 'test player' player = main.Player(name) result = main.Hand(player) die_a = main.Die() die_b = main.Die() die_c = main.Die() result.keep_roll(die_a.roll()) result.keep_roll(die_b.roll()) result.keep_roll(die_c.roll()) self.assertEqual(len(result.rolls), 3)
def test_hand_display_hand_not_empty(self): name = 'test player' player = main.Player(name) hand = main.Hand(player) die_a = main.Die() die_b = main.Die() hand.keep_roll(die_a.roll()) hand.keep_roll(die_a.roll()) result = io.StringIO() sys.stdout = result hand.display_hand() result = result.getvalue().rstrip() self.assertEqual(result.count('o'), sum(hand.rolls))
def test_hand_qualified(self): name = 'test player' player = main.Player(name) hand = main.Hand(player) die_a = main.Die() hand.keep_roll(die_a.roll()) result = hand.qualified() self.assertEqual(result, False)
def test_hand_calc_score(self): name = 'test player' player = main.Player(name) hand = main.Hand(player) die_a = main.Die() hand.keep_roll(die_a.roll()) hand.calc_score() result = hand.score #self.assertEqual(result, 0) die_b = main.Die() die_c = main.Die() die_d = main.Die() hand.keep_roll(die_b.roll()) hand.keep_roll(die_c.roll()) hand.calc_score() result = hand.score if 1 in hand.rolls and 4 in hand.rolls: self.assertIn(result, hand.rolls) else: self.assertEqual(result, 0)
def test_die_roll(self): die = main.Die() result = die.roll() self.assertLessEqual(result,6)
def test_die_creation(self): result = main.Die() for face in result.die: self.assertLessEqual(face.value, 6)