docstr: When the field name is prefixed, it should be used as is.
  When not prefixed, we should add the prefix
  When there's a collision, the one that appears first in the list will be used.
docstr_tok: ["When","the","field","name","is","prefixed",",","it","should","be","used","as","is",".","When","not","prefixed",",","we","should","add","the","prefix","When","there","'s","a","collision",",","the","one","that","appears","first","in","the","list","will","be","used","."]
code: def test_connection_form__add_widgets_prefix_backcompat(
      self, scenario
  ):
      """
      When the field name is prefixed, it should be used as is.
      When not prefixed, we should add the prefix
      When there's a collision, the one that appears first in the list will be used.
      """
  
      class MyHook:
          conn_type = "test"
  
      provider_manager = ProvidersManager()
      widget_field = StringField(
          lazy_gettext("My Param"), widget=BS3TextFieldWidget()
      )
      dummy_field = BooleanField(
          label=lazy_gettext("Dummy param"), description="dummy"
      )
      widgets: dict[str, Field] = {}
      if scenario == "prefix":
          widgets["extra__test__my_param"] = widget_field
      elif scenario == "no_prefix":
          widgets["my_param"] = widget_field
      elif scenario == "both_1":
          widgets["my_param"] = widget_field
          widgets["extra__test__my_param"] = dummy_field
      elif scenario == "both_2":
          widgets["extra__test__my_param"] = widget_field
          widgets["my_param"] = dummy_field
      else:
          raise Exception("unexpected")
  
      provider_manager._add_widgets(
          package_name="abc",
          hook_class=MyHook,
          widgets=widgets,
      )
      assert (
          provider_manager.connection_form_widgets[
              "extra__test__my_param"
          ].field
          == widget_field
      )
  
imports: from __future__ import annotations
  import logging
  import re
  import sys
  from unittest.mock import patch
  import pytest
  from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
  from flask_babel import lazy_gettext
  from wtforms import BooleanField, Field, StringField
  from airflow.exceptions import AirflowOptionalProviderFeatureException
  from airflow.providers_manager import HookClassProvider, LazyDictWithCache, PluginInfo, ProviderInfo, ProvidersManager
label_desc: Use image node_id 13 for calling the TestProviderManager obj's underlying member method code with example usage: obj.test_connection_form__add_widgets_prefix_backcompat(scenario) without return types