rope / ropeidetest / formattertest.py

The trunk branch has multiple heads

import unittest

from ropeide.formatter import Formatter


class FormatterTest(unittest.TestCase):

    def setUp(self):
        super(FormatterTest, self).setUp()
        self.formatter = Formatter()

    def tearDown(self):
        super(FormatterTest, self).tearDown()

    def test_removing_extra_spaces(self):
        formatted = self.formatter.format('  \n')
        self.assertEquals('\n', formatted)

    def test_removing_extra_spaces2(self):
        formatted = self.formatter.format('def a_func():  \n    print(1)  \n  ')
        self.assertEquals('def a_func():\n    print(1)\n', formatted)

    def test_removing_extra_blank_lines2(self):
        formatted = self.formatter.format('a = 1\n\n\n\nb = 2\nc=3\n\nd=4\n')
        self.assertEquals('a = 1\n\n\nb = 2\nc=3\n\nd=4\n', formatted)

    def test_removing_extra_blank_lines3(self):
        formatted = self.formatter.format('\n\n\n\na = 1\n')
        self.assertEquals('\n\na = 1\n', formatted)

    def test_removing_extra_blank_lines_at_the_end_of_file(self):
        formatted = self.formatter.format('\n\n\n')
        self.assertEquals('\n', formatted)

    def test_removing_extra_blank_lines_at_the_end_of_file2(self):
        formatted = self.formatter.format('a = 1\n\n')
        self.assertEquals('a = 1\n', formatted)

    def test_inserting_new_line_at_the_end_of_file(self):
        formatted = self.formatter.format('a = 1')
        self.assertEquals('a = 1\n', formatted)

    def xxx_test_formatting_simple_equality(self):
        formatted = self.formatter.format('a_var       = 10\n')
        self.assertEquals('a_var = 10\n', formatted)


if __name__ == '__main__':
    unittest.main()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.