Exemple #1
0
 def test_my_split(self):
     """Test my_split finction from module task_2."""
     self.assertEqual(task_2.my_split("Python is cool", " "),
                      "Python is cool".split(' '))
     self.assertEqual(task_2.my_split(",,,,", ','), ",,,,".split(','))
     self.assertEqual(task_2.my_split("trololo", 'trololo'),
                      'trololo'.split('trololo'))
     self.assertEqual(task_2.my_split("Python", "Javascript"),
                      "Python".split("Javascript"))
     self.assertEqual(
         task_2.my_split('my brother broght brokoli bro', 'bro'),
         'my brother broght brokoli bro'.split('bro'))
     with self.assertRaises(ValueError):
         task_2.my_split("Python is cool", '')
Exemple #2
0
 def test_normal(self):
     """Check result when one character as separator."""
     self.assertEqual(my_split("raz dwa trzy", " "), ["raz", "dwa", "trzy"])
Exemple #3
0
 def test_compare_split_two_words(self):
     """Check result when string and separator are 2 different words."""
     string = "Python"
     separator = "Javascript"
     self.assertEqual(my_split(string, separator), string.split(separator))
Exemple #4
0
 def test_compare_split_string_only_containing_separator(self):
     """Check result when string contains only separators."""
     string = ",,,,"
     separator = ","
     self.assertEqual(my_split(string, separator), string.split(separator))
Exemple #5
0
 def test_compare_split_more_separators(self):
     """Check result when more than one separator between characters."""
     string = "raz   dwa   trzy"
     separator = " "
     self.assertEqual(my_split(string, separator), string.split(separator))
Exemple #6
0
 def test_compare_split_no_separator(self):
     """Check result when no separator in string."""
     string = "razdwatrzy"
     separator = " "
     self.assertEqual(my_split(string, separator), string.split(separator))
Exemple #7
0
 def test_compare_split_normal(self):
     """Check result when one character as separator."""
     string = "raz dwa trzy"
     separator = " "
     self.assertEqual(my_split(string, separator), string.split(separator))
Exemple #8
0
 def test_separator_is_empty_string(self):
     """Check result when provided separator is empty."""
     with self.assertRaises(ValueError):
         my_split("raz dwa trzy", "")
Exemple #9
0
 def test_separator_not_provided(self):
     """Check result when user does not provide separator argument."""
     self.assertEqual(my_split("raz dwa trzy"), ["raz", "dwa", "trzy"])
Exemple #10
0
 def test_string_only_containing_separator(self):
     """Check result when string contains only separators."""
     self.assertEqual(my_split(",,,,", ','), ['', '', '', '', ''])
Exemple #11
0
 def test_separator_not_a_string(self):
     """Check if correct msg when separator is not a string."""
     with self.assertRaises(TypeError):
         my_split("raz dwa trzy", 15)
Exemple #12
0
 def test_argument_not_a_string(self):
     """Check if correct msg when argument is not a string."""
     with self.assertRaises(TypeError):
         my_split(15, " ")
Exemple #13
0
 def test_more_separators(self):
     """Check result when more than one separator between characters."""
     self.assertEqual(my_split("raz   dwa   trzy", " "),
                      ['raz', '', '', 'dwa', '', '', 'trzy'])
Exemple #14
0
 def test_no_separator_in_string(self):
     """Check result when no separator in string."""
     self.assertEqual(my_split("razdwatrzy", " "), ["razdwatrzy"])