code: def Test_figure_legends_DEPRECATED(obejct):
      def test_glyph_label_is_legend_if_column_in_datasource_is_added_as_legend(
          self, p, source
      ) -> None:
          p.scatter(x="x", y="y", legend="label", source=source)
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].label == {"field": "label"}
  
      def test_glyph_label_is_value_if_column_not_in_datasource_is_added_as_legend(
          self, p, source
      ) -> None:
          p.scatter(x="x", y="y", legend="milk", source=source)
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].label == {"value": "milk"}
  
      def test_glyph_label_is_legend_if_column_in_df_datasource_is_added_as_legend(
          self, p
      ) -> None:
          source = pd.DataFrame(
              data=dict(x=[1, 2, 3], y=[1, 2, 3], label=["a", "b", "c"])
          )
          p.scatter(x="x", y="y", legend="label", source=source)
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].label == {"field": "label"}
  
      def test_glyph_label_is_value_if_column_not_in_df_datasource_is_added_as_legend(
          self, p
      ) -> None:
          source = pd.DataFrame(
              data=dict(x=[1, 2, 3], y=[1, 2, 3], label=["a", "b", "c"])
          )
          p.scatter(x="x", y="y", legend="milk", source=source)
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].label == {"value": "milk"}
  
      def test_glyph_label_is_just_added_directly_if_not_string(
          self, p, source
      ) -> None:
          p.scatter(
              x="x", y="y", legend={"field": "milk"}, source=source
          )
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].label == {"field": "milk"}
  
      def test_no_legend_if_legend_is_none(self, p, source) -> None:
          p.scatter(x="x", y="y", legend=None, source=source)
          legends = p.select(Legend)
          assert len(legends) == 0
  
      def test_legend_added_when_legend_set(self, p, source) -> None:
          renderer = p.scatter(
              x="x", y="y", legend="label", source=source
          )
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].renderers == [renderer]
  
      def test_legend_not_added_when_no_legend(self, p, source) -> None:
          p.scatter(x="x", y="y", source=source)
          legends = p.select(Legend)
          assert len(legends) == 0
  
      def test_adding_legend_doesnt_work_when_legends_already_added(
          self, p, source
      ) -> None:
          p.add_layout(Legend())
          p.add_layout(Legend())
          with pytest.raises(RuntimeError):
              p.scatter(x="x", y="y", legend="label", source=source)
  
      def test_multiple_renderers_correctly_added_to_legend(
          self, p, source
      ) -> None:
          square = p.scatter(
              x="x",
              y="y",
              marker="square",
              legend="square",
              source=source,
          )
          circle = p.scatter(
              x="x",
              y="y",
              marker="circle",
              legend="circle",
              source=source,
          )
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].renderers == [square]
          assert legends[0].items[0].label == value("square")
          assert legends[0].items[1].renderers == [circle]
          assert legends[0].items[1].label == value("circle")
  
      def test_compound_legend_behavior_initiated_if_labels_are_same_on_multiple_renderers(
          self, p, source
      ) -> None:
          # 'compound legend string' is just a value
          square = p.scatter(
              x="x",
              y="y",
              marker="square",
              legend="compound legend string",
          )
          circle = p.scatter(
              x="x",
              y="y",
              marker="circle",
              legend="compound legend string",
          )
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].renderers == [square, circle]
          assert legends[0].items[0].label == value(
              "compound legend string"
          )
  
      def test_compound_legend_behavior_initiated_if_labels_are_same_on_multiple_renderers_and_are_field(
          self, p, source
      ) -> None:
          # label is a field
          square = p.scatter(
              x="x",
              y="y",
              marker="square",
              legend="label",
              source=source,
          )
          circle = p.scatter(
              x="x",
              y="y",
              marker="circle",
              legend="label",
              source=source,
          )
          legends = p.select(Legend)
          assert len(legends) == 1
          assert legends[0].items[0].renderers == [square, circle]
          assert legends[0].items[0].label == {"field": "label"}
  
imports: from __future__ import annotations
  import pytest
  import re
  import pandas
  from bokeh.core.enums import MarkerType
  from bokeh.core.properties import value
  from bokeh.models import BoxZoomTool, Circle, ColumnDataSource, LassoSelectTool, Legend, LinearAxis, LogScale, PanTool, ResetTool, Scatter, Title
  from bokeh.util.warnings import BokehDeprecationWarning
  from bokeh.plotting import _figure
label_desc: Use image node_id 1 for calling a global function with example usage: Test_figure_legends_DEPRECATED(obejct) without return types