Exemplo n.º 1
0
 def assertCompletionsDoNotInclude(self,
                                   markedup_content,
                                   completions,
                                   implicit=True):
     """Check that the given completions are NOT found
     @param markedup_content Content with a <|> marking
     @param completions List of expected completions; each item is a tuple of
         (type, completion string)
     @param implicit Whether the trigger should be implicit
     """
     actual_completions = self._doEval(markedup_content,
                                       implicit=implicit).completions
     extra_completions = set()
     for typ, cpln in completions:
         if UIHandler.AutoCompleteInfo(cpln, typ) in actual_completions:
             extra_completions.add((typ, cpln))
     self.failIf(
         extra_completions and True,
         "%s completions at the given position included "
         "some unexpected values\n"
         "  shouldn't have had these: %r\n"
         "  expected none of:         %r\n"
         "  got:                      %r\n"
         "  buffer:\n%s" %
         (self.language, list(extra_completions), completions, [
             (cpln.type, cpln.completion) for cpln in actual_completions
         ], indent(markedup_content)))
Exemplo n.º 2
0
 def assertCompletionsInclude(self,
                              markedup_content,
                              completions,
                              implicit=True):
     """Check that the given completions are found
     @param markedup_content Content with a <|> marking
     @param completions List of expected completions; each item is a tuple of
         (type, completion string)
     @param implicit Whether the trigger should be implicit
     """
     actual_completions = self._doEval(markedup_content,
                                       implicit=implicit).completions
     missing_completions = set()
     for typ, cpln in completions:
         if UIHandler.AutoCompleteInfo(cpln, typ) not in actual_completions:
             missing_completions.add((typ, cpln))
     self.failIf(
         missing_completions and True,
         "%s completions at the given position did not "
         "include all expected values\n"
         "  missing:         %r\n"
         "  expected all of: %r\n"
         "  got:             %r\n"
         "  buffer:\n%s" %
         (self.language, list(missing_completions), completions, [
             (cpln.type, cpln.completion) for cpln in actual_completions
         ], indent(markedup_content)))
Exemplo n.º 3
0
 def test_completion(self):
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.trg_from_pos(self.positions[1], True, spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_CPLN)
     # don't really care about the rest of the internals of the trigger
     # as long as it actually works...
     spinner = AsyncSpinner(self)
     with spinner:
         handler = UIHandler(spinner)
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     self.assertIn(UIHandler.AutoCompleteInfo("sys", "module"),
                   handler.completions)