예제 #1
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)
    if PY2:
        return occurrences.next()  # Python 2.7
    return occurrences.__next__()  # DEBUG .next() Python 3
예제 #2
0
 def test_first_occurrences_are_from_the_same_file(self):
     occ = self.resu.execute(FindOccurrences('My Keyword'))
     # see https://stackoverflow.com/questions/21622193/
     # python-3-2-coroutine-attributeerror-generator-object-has-no-attribute-next
     assert_true(
         self.resu.filename.endswith(occ.__next__().item.parent.source))
     assert_equal(occ.__next__().source, self.ts2.source)
     assert_equal(occ.__next__().source, self.ts2.source)
예제 #3
0
파일: commands.py 프로젝트: lf1687/MyTools
 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
예제 #4
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
예제 #5
0
 def test_unknown_variable_occurrences(self):
     self.assertEqual(
         list(
             self.test_ctrl.execute(
                 FindOccurrences('${some unknown variable}'))), [])
예제 #6
0
 def test_no_occurrences(self):
     find_occurrences = FindOccurrences('Keyword Name')
     occurrences = self.test_ctrl.execute(find_occurrences)
     assert_equal([i for i in occurrences], [])
예제 #7
0
 def assert_occurrences(self, ctrl, kw_name, count):
     assert_equal(sum(1 for _ in ctrl.execute(FindOccurrences(kw_name))),
                  count)
예제 #8
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 next(occurrences)