code: def test_pattern_matching(gallery_conf, log_collector):
      """Test if only examples matching pattern are executed"""
  
      gallery_conf.update(filename_pattern=re.escape(os.sep) + "plot_0")
  
      code_output = (
          "\n Out::\n"
          "\n"
          "    Óscar output\n"
          "    log:Óscar\n"
          "    $\\langle n_\\uparrow n_\\downarrow \\rangle$\n\n"
      )
      # create three files in tempdir (only one matches the pattern)
      fnames = ["plot_0.py", "plot_1.py", "plot_2.py"]
      for fname in fnames:
          with codecs.open(
              os.path.join(gallery_conf["examples_dir"], fname),
              mode="w",
              encoding="utf-8",
          ) as f:
              f.write("\n".join(CONTENT))
          # generate rst file
          sg.generate_file_rst(
              fname,
              gallery_conf["gallery_dir"],
              gallery_conf["examples_dir"],
              gallery_conf,
          )
          # read rst file and check if it contains code output
          rst_fname = os.path.splitext(fname)[0] + ".rst"
          with codecs.open(
              os.path.join(gallery_conf["gallery_dir"], rst_fname),
              mode="r",
              encoding="utf-8",
          ) as f:
              rst = f.read()
          if re.search(
              gallery_conf["filename_pattern"],
              os.path.join(gallery_conf["gallery_dir"], rst_fname),
          ):
              assert code_output in rst
          else:
              assert code_output not in rst
  
imports: from __future__ import division, absolute_import, print_function, unicode_literals
  import ast
  import codecs
  import copy
  import logging
  import tempfile
  import re
  import os
  import shutil
  import zipfile
  import pytest
  import sphinx_gallery.gen_rst
  from sphinx_gallery import gen_gallery, downloads
  from sphinx_gallery.gen_gallery import generate_dir_rst
  from sphinx_gallery import sphinx_compatibility
  import matplotlib.pyplot
label_desc: Use image node_id 10 for calling a global function with example usage: test_pattern_matching(gallery_conf, log_collector) without return types