Anonymous avatar Anonymous committed aefdcae

findittest: moved related tests from codeassisttest

Comments (0)

Files changed (3)

ropetest/contrib/__init__.py

 
 import ropetest.contrib.autoimporttest
 import ropetest.contrib.codeassisttest
+import ropetest.contrib.findittest
 import ropetest.contrib.generatetest
 
 
     result.addTests(unittest.makeSuite(ropetest.contrib.generatetest.GenerateTest))
     result.addTests(ropetest.contrib.codeassisttest.suite())
     result.addTests(ropetest.contrib.autoimporttest.suite())
+    result.addTests(ropetest.contrib.findittest.suite())
     return result
 
 

ropetest/contrib/codeassisttest.py

                                      sorted_proposals, starting_offset,
                                      get_calltip)
 from ropetest import testutils
-from rope.contrib.findit import find_occurrences
 
 
 class CodeAssistTest(unittest.TestCase):
         self.assertEquals('l.app', starting_expression(code, len(code)))
 
 
-class FindItTest(unittest.TestCase):
-
-    def setUp(self):
-        super(FindItTest, self).setUp()
-        self.project = testutils.sample_project()
-
-    def tearDown(self):
-        testutils.remove_project(self.project)
-        super(FindItTest, self).tearDown()
-
-    def test_finding_occurrences(self):
-        mod = testutils.create_module(self.project, 'mod')
-        mod.write('a_var = 1\n')
-        result = find_occurrences(self.project, mod, 1)
-        self.assertEquals(mod, result[0].resource)
-        self.assertEquals(0, result[0].offset)
-        self.assertEquals(False, result[0].unsure)
-
-    def test_finding_occurrences_in_more_than_one_module(self):
-        mod1 = testutils.create_module(self.project, 'mod1')
-        mod2 = testutils.create_module(self.project, 'mod2')
-        mod1.write('a_var = 1\n')
-        mod2.write('import mod1\nmy_var = mod1.a_var')
-        result = find_occurrences(self.project, mod1, 1)
-        self.assertEquals(2, len(result))
-        modules = (result[0].resource, result[1].resource)
-        self.assertTrue(mod1 in modules and mod2 in modules)
-
-    def test_finding_occurrences_matching_when_unsure(self):
-        mod1 = testutils.create_module(self.project, 'mod1')
-        mod1.write('class C(object):\n    def a_func(self):\n        pass\n'
-                   'def f(arg):\n    arg.a_func()\n')
-        result = find_occurrences(
-            self.project, mod1, mod1.read().index('a_func'), unsure=True)
-        self.assertEquals(2, len(result))
-
-    def test_find_occurrences_resources_parameter(self):
-        mod1 = testutils.create_module(self.project, 'mod1')
-        mod2 = testutils.create_module(self.project, 'mod2')
-        mod1.write('a_var = 1\n')
-        mod2.write('import mod1\nmy_var = mod1.a_var')
-        result = find_occurrences(self.project, mod1, 1, resources=[mod1])
-        self.assertEquals(1, len(result))
-        self.assertEquals((mod1, 0), (result[0].resource, result[0].offset))
-
-    def test_find_occurrences_and_class_hierarchies(self):
-        mod1 = testutils.create_module(self.project, 'mod1')
-        mod1.write('class A(object):\n    def f():\n        pass\n'
-                   'class B(A):\n    def f():\n        pass\n')
-        offset = mod1.read().rindex('f')
-        result1 = find_occurrences(self.project, mod1, offset)
-        result2 = find_occurrences(self.project, mod1,
-                                   offset, in_hierarchy=True)
-        self.assertEquals(1, len(result1))
-        self.assertEquals(2, len(result2))
-
-
 def suite():
     result = unittest.TestSuite()
     result.addTests(unittest.makeSuite(CodeAssistTest))
     result.addTests(unittest.makeSuite(CodeAssistInProjectsTest))
-    result.addTests(unittest.makeSuite(FindItTest))
     return result
 
 if __name__ == '__main__':

ropetest/contrib/findittest.py

+import unittest
+
+from rope.contrib.findit import find_occurrences
+from ropetest import testutils
+
+
+class FindItTest(unittest.TestCase):
+
+    def setUp(self):
+        super(FindItTest, self).setUp()
+        self.project = testutils.sample_project()
+
+    def tearDown(self):
+        testutils.remove_project(self.project)
+        super(FindItTest, self).tearDown()
+
+    def test_finding_occurrences(self):
+        mod = testutils.create_module(self.project, 'mod')
+        mod.write('a_var = 1\n')
+        result = find_occurrences(self.project, mod, 1)
+        self.assertEquals(mod, result[0].resource)
+        self.assertEquals(0, result[0].offset)
+        self.assertEquals(False, result[0].unsure)
+
+    def test_finding_occurrences_in_more_than_one_module(self):
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
+        mod1.write('a_var = 1\n')
+        mod2.write('import mod1\nmy_var = mod1.a_var')
+        result = find_occurrences(self.project, mod1, 1)
+        self.assertEquals(2, len(result))
+        modules = (result[0].resource, result[1].resource)
+        self.assertTrue(mod1 in modules and mod2 in modules)
+
+    def test_finding_occurrences_matching_when_unsure(self):
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod1.write('class C(object):\n    def a_func(self):\n        pass\n'
+                   'def f(arg):\n    arg.a_func()\n')
+        result = find_occurrences(
+            self.project, mod1, mod1.read().index('a_func'), unsure=True)
+        self.assertEquals(2, len(result))
+
+    def test_find_occurrences_resources_parameter(self):
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod2 = testutils.create_module(self.project, 'mod2')
+        mod1.write('a_var = 1\n')
+        mod2.write('import mod1\nmy_var = mod1.a_var')
+        result = find_occurrences(self.project, mod1, 1, resources=[mod1])
+        self.assertEquals(1, len(result))
+        self.assertEquals((mod1, 0), (result[0].resource, result[0].offset))
+
+    def test_find_occurrences_and_class_hierarchies(self):
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod1.write('class A(object):\n    def f():\n        pass\n'
+                   'class B(A):\n    def f():\n        pass\n')
+        offset = mod1.read().rindex('f')
+        result1 = find_occurrences(self.project, mod1, offset)
+        result2 = find_occurrences(self.project, mod1,
+                                   offset, in_hierarchy=True)
+        self.assertEquals(1, len(result1))
+        self.assertEquals(2, len(result2))
+
+
+def suite():
+    result = unittest.TestSuite()
+    result.addTests(unittest.makeSuite(FindItTest))
+    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.