# Path: ml_collections/config_flags/config_path.py
# _AST_SPLIT_CONFIG_PATH = {
#     ast.Attribute: lambda n: (*_split_node(n.value), n.attr),
#     ast.Index: lambda i: _split_node(i.value),
#     ast.Name: lambda n: (n.id,),
#     ast.Slice: lambda i: slice(*map(_split_node, (i.lower, i.upper, i.step))),
#     ast.Subscript: lambda n: (*_split_node(n.value), _split_node(n.slice)),
#     type(None): lambda n: None
# }
# def _split_node(node):
# def split(config_path: str) -> Tuple[Any]:
# def _get_item_or_attribute(config, field):
# def _get_holder_field(config_path: str, config: Any) -> Tuple[Any, str]:
# def get_value(config_path: str, config: Any):
# def get_type(config_path: str, config: Any):
# def set_value(config_path: str, config: Any, value: Any):
# 
# Path: ml_collections/config_flags/tests/fieldreference_config.py
# def get_config():
# 
# Path: ml_collections/config_flags/tests/mock_config.py
# class TestConfig(object):
#   def __init__(self):
#   def readonly_field(self):
#   def __repr__(self):
# def get_config():


from absl.testing import absltest
from absl.testing import parameterized
from ml_collections.config_flags import config_path
from ml_collections.config_flags.tests import fieldreference_config
from ml_collections.config_flags.tests import mock_config
  def test_list_out_of_range_set(self):
    """Tries to override out-of-range value in list."""

    test_config = mock_config.get_config()
    with self.assertRaises(IndexError):
      config_path.set_value('dict.list[2][1]', test_config, -1)

  def test_reading_non_existing_key(self):
    """Tests reading non existing key from config."""

    test_config = mock_config.get_config()
    with self.assertRaises(KeyError):
      config_path.set_value('dict.not_existing_key', test_config, 1)

  def test_reading_setting_existing_key_in_dict(self):
    """Tests setting non existing key from dict inside config."""

    test_config = mock_config.get_config()
    with self.assertRaises(KeyError):
      config_path.set_value('dict.not_existing_key.key', test_config, 1)

  def test_empty_key(self):
    """Tests calling an empty key update."""

    test_config = mock_config.get_config()
    with self.assertRaises(ValueError):
      config_path.set_value('', test_config, None)

  def test_field_reference_types(self):
    """Tests whether types of FieldReference fields are valid."""

# Path: ml_collections/config_flags/config_path.py
# _AST_SPLIT_CONFIG_PATH = {
#     ast.Attribute: lambda n: (*_split_node(n.value), n.attr),
#     ast.Index: lambda i: _split_node(i.value),
#     ast.Name: lambda n: (n.id,),
#     ast.Slice: lambda i: slice(*map(_split_node, (i.lower, i.upper, i.step))),
#     ast.Subscript: lambda n: (*_split_node(n.value), _split_node(n.slice)),
#     type(None): lambda n: None
# }
# def _split_node(node):
# def split(config_path: str) -> Tuple[Any]:
# def _get_item_or_attribute(config, field):
# def _get_holder_field(config_path: str, config: Any) -> Tuple[Any, str]:
# def get_value(config_path: str, config: Any):
# def get_type(config_path: str, config: Any):
# def set_value(config_path: str, config: Any, value: Any):
# 
# Path: ml_collections/config_flags/tests/fieldreference_config.py
# def get_config():
# 
# Path: ml_collections/config_flags/tests/mock_config.py
# class TestConfig(object):
#   def __init__(self):
#   def readonly_field(self):
#   def __repr__(self):
# def get_config():


# Path: ml_collections/config_flags/tests/config_path_test.py
from absl.testing import absltest
from absl.testing import parameterized
from ml_collections.config_flags import config_path
from ml_collections.config_flags.tests import fieldreference_config
from ml_collections.config_flags.tests import mock_config

  def test_list_out_of_range_set(self):
    """Tries to override out-of-range value in list."""

    test_config = mock_config.get_config()
    with self.assertRaises(IndexError):
      config_path.set_value('dict.list[2][1]', test_config, -1)

  def test_reading_non_existing_key(self):
    """Tests reading non existing key from config."""

    test_config = mock_config.get_config()
    with self.assertRaises(KeyError):
      config_path.set_value('dict.not_existing_key', test_config, 1)

  def test_reading_setting_existing_key_in_dict(self):
    """Tests setting non existing key from dict inside config."""

    test_config = mock_config.get_config()
    with self.assertRaises(KeyError):
      config_path.set_value('dict.not_existing_key.key', test_config, 1)

  def test_empty_key(self):
    """Tests calling an empty key update."""

    test_config = mock_config.get_config()
    with self.assertRaises(ValueError):
      config_path.set_value('', test_config, None)

  def test_field_reference_types(self):
    """Tests whether types of FieldReference fields are valid."""

    test_config = fieldreference_config.get_config()