Example #1
0
 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",
     )
Example #2
0
 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",
     )
Example #3
0
# 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)
Example #4
0
 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")
Example #5
0
 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")
Example #6
0
# 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)