code: def test_completer():
      class completer1(Completer):
          def get_completions(self, document, complete_event):
              yield Completion(
                  "before-%s-after" % document.text, -len(document.text)
              )
              yield Completion(
                  "before-%s-after-B" % document.text,
                  -len(document.text),
              )
  
      class completer2(Completer):
          def get_completions(self, document, complete_event):
              yield Completion(
                  "before2-%s-after2" % document.text,
                  -len(document.text),
              )
              yield Completion(
                  "before2-%s-after2-B" % document.text,
                  -len(document.text),
              )
  
      # Create grammar.  "var1" + "whitespace" + "var2"
      g = compile(r"(?P<var1>[a-z]*) \s+ (?P<var2>[a-z]*)")
  
      # Test 'get_completions()'
      completer = GrammarCompleter(
          g, {"var1": completer1(), "var2": completer2()}
      )
      completions = list(
          completer.get_completions(
              Document("abc def", len("abc def")), CompleteEvent()
          )
      )
  
      assert len(completions) == 2
      assert completions[0].text == "before2-def-after2"
      assert completions[0].start_position == -3
      assert completions[1].text == "before2-def-after2-B"
      assert completions[1].start_position == -3
  
file_path: catboost/contrib/python/prompt-toolkit/py2/tests/test_regular_languages.py
imports: from __future__ import unicode_literals
  from prompt_toolkit.completion import CompleteEvent, Completer, Completion
  from prompt_toolkit.contrib.regular_languages import compile
  from prompt_toolkit.contrib.regular_languages.compiler import Match, Variables
  from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter
  from prompt_toolkit.document import Document
label_desc: Use image node_id 4 for calling a global function with example usage: test_completer() without return types