code: def test_pathcompleter_completes_directories_with_only_directories():
      # setup: create a test dir with 10 files
      test_dir = tempfile.mkdtemp()
      write_test_files(test_dir)
  
      # create a sub directory there
      os.mkdir(os.path.join(test_dir, "subdir"))
  
      if not test_dir.endswith(os.path.sep):
          test_dir += os.path.sep
  
      with chdir(test_dir):
          completer = PathCompleter(only_directories=True)
          doc_text = ""
          doc = Document(doc_text, len(doc_text))
          event = CompleteEvent()
          completions = list(completer.get_completions(doc, event))
          result = [c.text for c in completions]
          assert ["subdir"] == result
  
      # check that there is no completion when passing a file
      with chdir(test_dir):
          completer = PathCompleter(only_directories=True)
          doc_text = "1"
          doc = Document(doc_text, len(doc_text))
          event = CompleteEvent()
          completions = list(completer.get_completions(doc, event))
          assert [] == completions
  
      # cleanup
      shutil.rmtree(test_dir)
  
imports: from __future__ import annotations
  import os
  import re
  import shutil
  import tempfile
  from contextlib import contextmanager
  from prompt_toolkit.completion import CompleteEvent, FuzzyWordCompleter, NestedCompleter, PathCompleter, WordCompleter, merge_completers
  from prompt_toolkit.document import Document
label_desc: Use image node_id 6 for calling a global function with example usage: test_pathcompleter_completes_directories_with_only_directories() without return types