Exemple #1
0
 def test_substitute_hand_not_same_letter(self):        
     # test 2
     hand = {'a': 1, 'r': 1, 'e': 1, 'j': 2, 'm': 1, '@': 1}
     letter = "r"
     try:
         new_hand = ps3.substitute_hand(hand, letter)
         self.assertFalse('r' in new_hand and new_hand['r'] !=0, "In substitute_hand you should not get back a letter already in the hand (or the letter you are substituting)")
     except NotImplementedError as e:
                     self.fail(NOT_IMPLEMENTED)  
Exemple #2
0
    def test_substitute_hand_vowel(self):
        """
        Unit test for substitute_hand
        """
        for i in range(20):
            # test 1
            hand = {'a': 1, 'r': 1, 'e': 1, 'j': 2, 'm': 1, '@': 1}
            letter = "a"
            try:
                new_hand = ps3.substitute_hand(hand, letter)

                result = 'o' in new_hand or 'i' in new_hand or 'u' in new_hand
                self.assertTrue(result, "In substitute_hand you should only be able to subsitute a vowel for a vowel and should not be able to get back a letter already in the hand")
            except NotImplementedError as e:
                self.fail(NOT_IMPLEMENTED)  
Exemple #3
0
 def test_substitute_hand_constonant(self):        
     # test 2
     #do multiple times to make sure they arent passing by chance
     for i in range(100):
         hand = {'r': 1}
         letter = "r"
         try:
             new_hand = ps3.substitute_hand(hand, letter)
             hand_keys = list(new_hand.keys())
             try:
                 hand_keys.remove(letter)
             except ValueError:
                 pass  # do nothing!
             self.assertTrue(len(hand_keys)>0, "In substitute_hand your new letter should not be your old letter")
             new_letter = hand_keys[0]
             self.assertIn(new_letter, CONSONANTS, "In substitute_hand you should only be able to substitute constant for a constant")
         except NotImplementedError as e:
             self.fail(NOT_IMPLEMENTED)