Example #1
0
    def test_index(self):
        """Test the index part of the function."""
        text = 'a\nb\nc'
        expected_pos = [2, 4, -1]
        for res, expected in zip(split_by_newline(text), expected_pos):
            self.assertEqual(res[0], expected)

        text = 'a\nb\nc\n'
        expected_pos = [2, 4, 6, -1]
        for res, expected in zip(split_by_newline(text), expected_pos):
            self.assertEqual(res[0], expected)
Example #2
0
    def test_index(self):
        """Test the index part of the function."""
        text = 'a\nb\nc'
        expected_pos = [2, 4, -1]
        for res, expected in zip(split_by_newline(text), expected_pos):
            self.assertEqual(res[0], expected)

        text = 'a\nb\nc\n'
        expected_pos = [2, 4, 6, -1]
        for res, expected in zip(split_by_newline(text), expected_pos):
            self.assertEqual(res[0], expected)
Example #3
0
 def test_ends_character(self):
     """Test the behavior in case the text does not end
     with a new line character.
     """
     text = 'A line\nAnother line\nAnd a final one.'
     expected_res = text.split('\n')
     for res, expected in zip(split_by_newline(text), expected_res):
         self.assertEqual(res[1], expected)
Example #4
0
 def test_ends_character(self):
     """Test the behavior in case the text does not end
     with a new line character.
     """
     text = 'A line\nAnother line\nAnd a final one.'
     expected_res = text.split('\n')
     for res, expected in zip(split_by_newline(text), expected_res):
         self.assertEqual(res[1], expected)
Example #5
0
 def test_empty_text(self):
     """Test with empty text."""
     it = split_by_newline('')
     _, s = it.next()
     self.assertEqual(s, '')
     self.assertRaises(StopIteration, it.next)
Example #6
0
 def test_empty_text(self):
     """Test with empty text."""
     it = split_by_newline('')
     _, s = it.next()
     self.assertEqual(s, '')
     self.assertRaises(StopIteration, it.next)