def test_unix_utf8_strip_newlines(self):
        resulting = self._get_textbuffer('unix_utf8_stripped_newlines.txt')

        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix,
                                                       False)

        self.assertEqualContents(resulting, self.raw_unix)
Exemplo n.º 2
0
    def test_unix_utf8_strip_whitespace(self):
        resulting = self._get_textbuffer('unix_utf8_stripped_whitespace.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(
            self.raw_unix, False)

        self.assertEqualContents(resulting, self.raw_unix)
    def test_unix_utf8_strip_whitespace(self):
        resulting = self._get_textbuffer('unix_utf8_stripped_whitespace.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(self.raw_unix,
                                                           False)

        self.assertEqualContents(resulting, self.raw_unix)
Exemplo n.º 4
0
    def test_different_line_endings(self):
        raw_different = self._get_textbuffer('different_utf8_raw.txt')

        resulting = self._get_textbuffer(
            'different_utf8_stripped_newlines.txt')

        DocumentManipulator.strip_trailing_blank_lines(raw_different, False)

        self.assertEqualContents(resulting, raw_different)
    def test_different_line_endings(self):
        raw_different = self._get_textbuffer('different_utf8_raw.txt')

        resulting = self._get_textbuffer(
            'different_utf8_stripped_newlines.txt')

        DocumentManipulator.strip_trailing_blank_lines(raw_different,
                                                       False)

        self.assertEqualContents(resulting, raw_different)
Exemplo n.º 6
0
    def test_win_utf8_strip_whitespace_then_newlines(self):
        raw_win = self._get_textbuffer('win_utf8_raw.txt')

        resulting = self._get_textbuffer(
            'win_utf8_stripped_whitespace_then_newlines.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(raw_win, False)
        DocumentManipulator.strip_trailing_blank_lines(raw_win, False)

        self.assertEqualContents(resulting, raw_win)
Exemplo n.º 7
0
    def _on_saving(self, doc, *args):
        """Strip trailing spaces in document."""

        doc.begin_user_action()
        if (self._config.get_bool('remove_whitespace')):
            DocumentManipulator.strip_trailing_spaces_on_lines(doc)

        if (self._config.get_bool('remove_newlines')):
            DocumentManipulator.strip_trailing_blank_lines(doc)

        doc.end_user_action()
    def test_win_utf8_strip_whitespace_then_newlines(self):
        raw_win = self._get_textbuffer('win_utf8_raw.txt')

        resulting = self._get_textbuffer(
            'win_utf8_stripped_whitespace_then_newlines.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(raw_win,
                                                           False)
        DocumentManipulator.strip_trailing_blank_lines(raw_win,
                                                       False)

        self.assertEqualContents(resulting, raw_win)
Exemplo n.º 9
0
    def test_preserve_cursor(self):
        resulting = self._get_textbuffer(
            'unix_utf8_stripped_whitespace_then_newlines_cursor_near_end.txt')

        near_end = self.raw_unix.get_iter_at_line_offset(9, 1)

        self.raw_unix.place_cursor(near_end)

        DocumentManipulator.strip_trailing_spaces_on_lines(self.raw_unix, True)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix, True)

        self.assertEqualContents(resulting, self.raw_unix)
    def test_preserve_cursor(self):
        resulting = self._get_textbuffer(
            'unix_utf8_stripped_whitespace_then_newlines_cursor_near_end.txt')

        near_end = self.raw_unix.get_iter_at_line_offset(9, 1)

        self.raw_unix.place_cursor(near_end)

        DocumentManipulator.strip_trailing_spaces_on_lines(self.raw_unix,
                                                           True)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix,
                                                       True)

        self.assertEqualContents(resulting, self.raw_unix)
Exemplo n.º 11
0
    def test_stripping_not_symmetrical(self):
        """NOTE: This is neither good nor bad, the test just shows it."""
        other_way = self._get_textbuffer('unix_utf8_raw.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(
            self.raw_unix, False)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix, False)

        DocumentManipulator.strip_trailing_blank_lines(other_way, False)
        DocumentManipulator.strip_trailing_spaces_on_lines(other_way, False)

        self.assertNotEqual(self._get_contents(self.raw_unix),
                            self._get_contents(other_way))
Exemplo n.º 12
0
    def test_unix_utf8_strip_newlines_multiple(self):
        resulting = self._get_textbuffer('unix_utf8_stripped_newlines.txt')

        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix, False)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix, False)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix, False)

        self.assertEqualContents(resulting, self.raw_unix)
    def test_stripping_not_symmetrical(self):
        """NOTE: This is neither good nor bad, the test just shows it."""
        other_way = self._get_textbuffer('unix_utf8_raw.txt')

        DocumentManipulator.strip_trailing_spaces_on_lines(self.raw_unix,
                                                           False)
        DocumentManipulator.strip_trailing_blank_lines(self.raw_unix,
                                                       False)

        DocumentManipulator.strip_trailing_blank_lines(other_way,
                                                       False)
        DocumentManipulator.strip_trailing_spaces_on_lines(other_way,
                                                           False)

        self.assertNotEqual(self._get_contents(self.raw_unix),
                            self._get_contents(other_way))