rope / ropetest / simplifytest.py

import unittest

from rope.base import simplify


class SimplifyTest(unittest.TestCase):

    def setUp(self):
        super(SimplifyTest, self).setUp()

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

    def test_trivial_case(self):
        self.assertEquals('', simplify.real_code(''))

    def test_empty_strs(self):
        code = 's = ""\n'
        self.assertEquals(code, simplify.real_code(code))

    def test_blanking_strs(self):
        code = 's = "..."\n'
        self.assertEquals('s = "   "\n', simplify.real_code(code))

    def test_changing_to_double_quotes(self):
        code = 's = \'\'\n'
        self.assertEquals('s = ""\n', simplify.real_code(code))

    def test_changing_to_double_quotes2(self):
        code = 's = """\n"""\n'
        self.assertEquals('s = "     "\n', simplify.real_code(code))

    def test_removing_comments(self):
        code = '# c\n'
        self.assertEquals('   \n', simplify.real_code(code))

    def test_removing_comments_that_contain_strings(self):
        code = '# "c"\n'
        self.assertEquals('     \n', simplify.real_code(code))

    def test_removing_strings_containing_comments(self):
        code = '"#c"\n'
        self.assertEquals('"  "\n', simplify.real_code(code))

    def test_joining_implicit_continuations(self):
        code = '(\n)\n'
        self.assertEquals('( )\n', simplify.real_code(code))

    def test_joining_explicit_continuations(self):
        code = '1 + \\\n 2\n'
        self.assertEquals('1 +    2\n', simplify.real_code(code))

    def test_replacing_tabs(self):
        code = '1\t+\t2\n'
        self.assertEquals('1 + 2\n', simplify.real_code(code))

    def test_replacing_semicolons(self):
        code = 'a = 1;b = 2\n'
        self.assertEquals('a = 1\nb = 2\n', simplify.real_code(code))


def suite():
    result = unittest.TestSuite()
    result.addTests(unittest.makeSuite(SimplifyTest))
    return result

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.