code: def test_fail_example(gallery_conf, log_collector):
      """Test that failing examples are only executed until failing block"""
  
      gallery_conf.update(filename_pattern="raise.py")
  
      failing_code = CONTENT + [
          "#" * 79,
          "First_test_fail",
          "#" * 79,
          "second_fail",
      ]
  
      with codecs.open(
          os.path.join(gallery_conf["examples_dir"], "raise.py"),
          mode="w",
          encoding="utf-8",
      ) as f:
          f.write("\n".join(failing_code))
  
      sg.generate_file_rst(
          "raise.py",
          gallery_conf["gallery_dir"],
          gallery_conf["examples_dir"],
          gallery_conf,
      )
      assert len(log_collector.calls["warning"]) == 1
      assert "not defined" in log_collector.calls["warning"][0].args[2]
  
      # read rst file and check if it contains traceback output
  
      with codecs.open(
          os.path.join(gallery_conf["gallery_dir"], "raise.rst"),
          mode="r",
          encoding="utf-8",
      ) as f:
          ex_failing_blocks = f.read().count("pytb")
          if ex_failing_blocks == 0:
              raise ValueError("Did not run into errors in bad code")
          elif ex_failing_blocks > 1:
              raise ValueError(
                  "Did not stop executing script after error"
              )
  
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 8 for calling a global function with example usage: test_fail_example(gallery_conf, log_collector) without return types