code: def test_raises_on_bad_indexed_underscore_property(some_fig):
      # The way these tests work is first the error is raised without using
      # underscores to get the Exception we expect, then the string showing the
      # bad property path is removed (because it will not match the string
      # returned when the same error is thrown using underscores).
      # Then the error is thrown using underscores and the Exceptions are
      # compared, but we adjust the expected bad property error because it will be
      # different when underscores are used.
  
      # finds bad part when using the path as a key to figure and throws the error
      # for the last good property it found in the path
      raised = False
      try:
          # get the error without using a path-like key, we compare with this error
          some_fig.data[0].line["colr"] = "blue"
      except ValueError as e_correct:
          raised = True
          # remove "Bad property path:
          e_correct_substr = error_substr(
              e_correct.args[0],
              """
  Bad property path:
  colr
  ^^^^""",
          )
      # if the string starts with "Bad property path:" then this test cannot work
      # this way.
      assert len(e_correct_substr) > 0
      assert raised
  
      raised = False
      try:
          some_fig["data[0].line_colr"] = "blue"
      except ValueError as e:
          raised = True
          e_substr = error_substr(
              e.args[0],
              """
  Bad property path:
  data[0].line_colr
               ^^^^""",
          )
          assert (
              (
                  e.args[0].find(
                      """Bad property path:
  data[0].line_colr
               ^^^^"""
                  )
                  >= 0
              )
              and (e.args[0].find("""Did you mean "color"?""") >= 0)
              and (e_substr == e_correct_substr)
          )
      assert raised
  
      raised = False
      try:
          # get the error without using a path-like key
          some_fig.add_trace(
              go.Scatter(x=[1, 2], y=[3, 4], line=dict(colr="blue"))
          )
      except ValueError as e_correct:
          raised = True
          e_correct_substr = error_substr(
              e_correct.args[0],
              """
  Bad property path:
  colr
  ^^^^""",
          )
      assert raised
  
      raised = False
      # finds bad part when using the path as a keyword argument to a subclass of
      # BasePlotlyType and throws the error for the last good property found in
      # the path
      try:
          some_fig.add_trace(
              go.Scatter(x=[1, 2], y=[3, 4], line_colr="blue")
          )
      except ValueError as e:
          raised = True
          e_substr = error_substr(
              e.args[0],
              """
  Bad property path:
  line_colr
       ^^^^""",
          )
          assert (
              (
                  e.args[0].find(
                      """Bad property path:
  line_colr
       ^^^^"""
                  )
                  and (e.args[0].find("""Did you mean "color"?""") >= 0)
                  >= 0
              )
              and (e_substr == e_correct_substr)
          )
      assert raised
  
      raised = False
      # finds bad part when using the path as a keyword argument to a subclass of
      # BaseFigure and throws the error for the last good property found in
      # the path
      try:
          fig2 = go.Figure(layout=dict(title=dict(txt="two")))
      except ValueError as e_correct:
          raised = True
          e_correct_substr = error_substr(
              e_correct.args[0],
              """
  Bad property path:
  txt
  ^^^""",
          )
      assert raised
  
      raised = False
      try:
          fig2 = go.Figure(layout_title_txt="two")
      except TypeError as e:
          raised = True
          # when the Figure constructor sees the same ValueError above, a
          # ValueError is raised and adds an error message in front of the same
          # ValueError thrown above
          e_substr = error_substr(
              e.args[0],
              """
  Bad property path:
  layout_title_txt
               ^^^""",
          )
          # also remove the invalid Figure property string added by the Figure constructor
          e_substr = error_substr(
              e_substr,
              """invalid Figure property: layout_title_txt
  """,
          )
          assert (
              (
                  e.args[0].find(
                      """Bad property path:
  layout_title_txt
               ^^^""",
                  )
                  >= 0
              )
              and (e.args[0].find("""Did you mean "text"?""") >= 0)
              and (e_substr == e_correct_substr)
          )
      assert raised
  
      raised = False
      # this is like the above test for subclasses of BasePlotlyType but makes sure it
      # works when the bad part is not the last part in the path
      try:
          some_fig.update_layout(geo=dict(ltaxis=dict(showgrid=True)))
      except ValueError as e_correct:
          raised = True
          e_correct_substr = error_substr(
              e_correct.args[0],
              """
  Bad property path:
  ltaxis
  ^^^^^^""",
          )
      assert raised
  
      raised = False
      try:
          some_fig.update_layout(geo_ltaxis_showgrid=True)
      except ValueError as e:
          raised = True
          e_substr = error_substr(
              e.args[0],
              """
  Bad property path:
  geo_ltaxis_showgrid
      ^^^^^^""",
          )
          assert (
              (
                  e.args[0].find(
                      """Bad property path:
  geo_ltaxis_showgrid
      ^^^^^^"""
                  )
                  >= 0
              )
              and (e.args[0].find("""Did you mean "lataxis"?""") >= 0)
              and (e_substr == e_correct_substr)
          )
      assert raised
  
imports: import plotly.graph_objects
  from _plotly_utils.exceptions import PlotlyKeyError
  import pytest
label_desc: Use image node_id 6 for calling a global function with example usage: test_raises_on_bad_indexed_underscore_property(some_fig) without return types