Ejemplo n.º 1
0
 def execute(self, context):
     prev = None
     for occ in FindOccurrences.execute(self, context):
         if isinstance(occ.item, KeywordNameController):
             continue
         if prev == occ:
             prev.count += 1
         else:
             if prev:
                 yield prev
             prev = occ
     if prev:
         yield prev
Ejemplo n.º 2
0
 def execute(self, context):
     prev = None
     for occ in FindOccurrences.execute(self, context):
         if isinstance(occ.item, KeywordNameController):
             continue
         if prev == occ:
             prev.count += 1
         else:
             if prev:
                 yield prev
             prev = occ
     if prev:
         yield prev
Ejemplo n.º 3
0
 def test_unknown_variable_occurrences(self):
     self.assertEqual(
         list(
             self.test_ctrl.execute(
                 FindOccurrences('${some unknown variable}'))), [])
Ejemplo n.º 4
0
 def test_no_occurrences(self):
     find_occurrences = FindOccurrences('Keyword Name')
     occurrences = self.test_ctrl.execute(find_occurrences)
     assert_equals([i for i in occurrences], [])
Ejemplo n.º 5
0
 def assert_occurrences(self, ctrl, kw_name, count):
     assert_equals(sum(1 for _ in ctrl.execute(FindOccurrences(kw_name))),
                   count)
Ejemplo n.º 6
0
 def test_first_occurrences_are_from_the_same_file(self):
     occ = self.resu.execute(FindOccurrences('My Keyword'))
     assert_true(self.resu.filename.endswith(occ.next().item.parent.source))
     assert_equals(occ.next().source, self.ts2.source)
     assert_equals(occ.next().source, self.ts2.source)
Ejemplo n.º 7
0
def _first_occurrence(test_ctrl, kw_name):
    occurrences = test_ctrl.execute(FindOccurrences(kw_name))
    if not occurrences:
        raise AssertionError('No occurrences found for "%s"' % kw_name)
    return occurrences.next()