def test_string_sorter_02(self): self.assertFalse( string_sorter(self.rand_str) == self.wrong_char_dict, "Calculated number of each character " "in rand_str should not be equal to " "number of characters in wrong_char_dict", )
def test_string_sorter_01(self): self.assertDictEqual( string_sorter(self.rand_str), self.char_dict, "Calculated number of each character in " "rand_str should be equal to " "number of characters in char_dict", )
# Modify Exercise 3-1 to extract all program logic in a separate module. import random import string from Lesson03.Exercise3_1_modified import string_sorter rand_str = ''.join(random.choice(string.lowercase) for _ in range(100)) string_sorter(rand_str)
def test_string_sorter_02(self): self.assertFalse( string_sorter(self.rand_str) == self.wrong_char_dict, "Calculated number of each character " "in rand_str should not be equal to " "number of characters in wrong_char_dict")
def test_string_sorter_01(self): self.assertDictEqual( string_sorter(self.rand_str), self.char_dict, "Calculated number of each character in " "rand_str should be equal to " "number of characters in char_dict")
# Modify Exercise 4-1 to define the string from command line. from Lesson03.Exercise3_1_modified import string_sorter rand_str = raw_input("\nPlease input any random string") string_sorter(rand_str)