コード例 #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
ファイル: test_occurrences.py プロジェクト: yvdhi/RIDE
 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
ファイル: commands.py プロジェクト: HelioGuilherme66/RIDE
 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
ファイル: test_occurrences.py プロジェクト: yvdhi/RIDE
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)